Expose redirect option on transport interface.
authorcantor <cantor@de75baf8-a10c-0410-a50a-987c0e22f00f>
Thu, 8 Jul 2010 20:40:10 +0000 (20:40 +0000)
committercantor <cantor@de75baf8-a10c-0410-a50a-987c0e22f00f>
Thu, 8 Jul 2010 20:40:10 +0000 (20:40 +0000)
git-svn-id: https://svn.middleware.georgetown.edu/cpp-xmltooling/branches/REL_1@761 de75baf8-a10c-0410-a50a-987c0e22f00f

xmltooling/soap/HTTPSOAPTransport.h
xmltooling/soap/impl/CURLSOAPTransport.cpp
xmltooling/soap/impl/SOAPClient.cpp

index ed2171e..81c0439 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2001-2009 Internet2
+ *  Copyright 2001-2010 Internet2
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -56,6 +56,14 @@ namespace xmltooling {
          * @return  true iff the header is successfully set
          */
         virtual bool setRequestHeader(const char* name, const char* value)=0;
+
+        /**
+         * Controls redirect behavior.
+         *
+         * @param follow    true iff Location-based redirects should be honored
+         * @param maxRedirs maximum number of redirects to permit
+         */
+        virtual bool followRedirects(bool follow, unsigned int maxRedirs);
         
         /**
          * Returns the values of an HTTP response header.
index 5dd48a3..130c89e 100644 (file)
@@ -148,6 +148,13 @@ namespace xmltooling {
             return true;
         }
 
+        bool followRedirects(bool follow, unsigned int maxRedirs) {
+            return (
+                curl_easy_setopt(m_handle, CURLOPT_FOLLOWLOCATION, (follow ? 1 : 0)) == CURLE_OK &&
+                curl_easy_setopt(m_handle, CURLOPT_MAXREDIRS, (follow ? maxRedirs : 0)) == CURLE_OK
+                );
+        }
+
         bool setCacheTag(string* cacheTag) {
             m_cacheTag = cacheTag;
             return true;
index 0449eb0..1e17c2d 100644 (file)
@@ -75,6 +75,11 @@ HTTPSOAPTransport::~HTTPSOAPTransport()
 {
 }
 
+bool HTTPSOAPTransport::followRedirects(bool follow, unsigned int maxRedirs)
+{
+    return false;
+}
+
 SOAPClient::SOAPClient(bool validate) : m_validate(validate), m_transport(nullptr)
 {
 }