https://bugs.internet2.edu/jira/browse/CPPXT-44
authorcantor <cantor@de75baf8-a10c-0410-a50a-987c0e22f00f>
Wed, 28 Oct 2009 17:41:29 +0000 (17:41 +0000)
committercantor <cantor@de75baf8-a10c-0410-a50a-987c0e22f00f>
Wed, 28 Oct 2009 17:41:29 +0000 (17:41 +0000)
git-svn-id: https://svn.middleware.georgetown.edu/cpp-xmltooling/branches/REL_1@665 de75baf8-a10c-0410-a50a-987c0e22f00f

xmltooling/soap/impl/CURLSOAPTransport.cpp
xmltooling/util/CurlURLInputStream.cpp
xmltooling/util/CurlURLInputStream.h

index 62d00e2..460a62e 100644 (file)
@@ -155,8 +155,11 @@ namespace xmltooling {
             if (opt < CURLOPTTYPE_OBJECTPOINT)
                 return (curl_easy_setopt(m_handle, opt, strtol(value, NULL, 10)) == CURLE_OK);
 #ifdef CURLOPTTYPE_OFF_T
-            else if (opt < CURLOPTTYPE_OFF_T)
-                return (curl_easy_setopt(m_handle, opt, value) == CURLE_OK);
+            else if (opt < CURLOPTTYPE_OFF_T) {
+                if (value)
+                    m_saved_options.push_back(value);
+                return (curl_easy_setopt(m_handle, opt, value ? m_saved_options.back().c_str() : NULL) == CURLE_OK);
+            }
 # ifdef HAVE_CURL_OFF_T
             else if (sizeof(curl_off_t) == sizeof(long))
                 return (curl_easy_setopt(m_handle, opt, strtol(value, NULL, 10)) == CURLE_OK);
@@ -166,8 +169,11 @@ namespace xmltooling {
 # endif
             return false;
 #else
-            else
-                return (curl_easy_setopt(m_handle, opt, value) == CURLE_OK);
+            else {
+                if (value)
+                    m_saved_options.push_back(value);
+                return (curl_easy_setopt(m_handle, opt, value ? m_saved_options.back().c_str() : NULL) == CURLE_OK);
+            }
 #endif
         }
 
@@ -213,6 +219,7 @@ namespace xmltooling {
         stringstream m_stream;
         struct curl_slist* m_headers;
         map<string,vector<string> > m_response_headers;
+        vector<string> m_saved_options;
 #ifndef XMLTOOLING_NO_XMLSEC
         const OpenSSLCredential* m_cred;
         const OpenSSLTrustEngine* m_trustEngine;
index f3b6dcd..2dbd77b 100644 (file)
@@ -200,8 +200,10 @@ void CurlURLInputStream::init(const DOMElement* e)
                     if (opt < CURLOPTTYPE_OBJECTPOINT)
                         success = (curl_easy_setopt(fEasy, opt, strtol(value.get(), NULL, 10)) == CURLE_OK);
 #ifdef CURLOPTTYPE_OFF_T
-                    else if (opt < CURLOPTTYPE_OFF_T)
-                        success = (curl_easy_setopt(fEasy, opt, value.get()) == CURLE_OK);
+                    else if (opt < CURLOPTTYPE_OFF_T) {
+                        fSavedOptions.push_back(value.get());
+                        success = (curl_easy_setopt(fEasy, opt, fSavedOptions.back().c_str()) == CURLE_OK);
+                    }
 # ifdef HAVE_CURL_OFF_T
                     else if (sizeof(curl_off_t) == sizeof(long))
                         success = (curl_easy_setopt(fEasy, opt, strtol(value.get(), NULL, 10)) == CURLE_OK);
@@ -212,8 +214,10 @@ void CurlURLInputStream::init(const DOMElement* e)
                     else
                         success = false;
 #else
-                    else
-                        success = (curl_easy_setopt(fEasy, opt, value.get()) == CURLE_OK);
+                    else {
+                        fSavedOptions.push_back(value.get());
+                        success = (curl_easy_setopt(fEasy, opt, fSavedOptions.back().c_str()) == CURLE_OK);
+                    }
 #endif
                     if (!success)
                         fLog.error("failed to set transport option (%s)", option.get());
index 6dfd02d..53b784f 100644 (file)
@@ -26,6 +26,8 @@
 
 #include <xmltooling/logging.h>
 
+#include <string>
+#include <vector>
 #include <curl/curl.h>
 #include <xercesc/util/BinInputStream.hpp>
 
@@ -100,6 +102,7 @@ namespace xmltooling {
 
         logging::Category&  fLog;
         std::string         fURL;
+        std::vector<std::string>    fSavedOptions;
 
         CURLM*              fMulti;
         CURL*               fEasy;