From baf2e0386f3a071f88f2443662cfa55e61176563 Mon Sep 17 00:00:00 2001 From: Scott Cantor Date: Wed, 28 Oct 2009 17:41:29 +0000 Subject: [PATCH] https://issues.shibboleth.net/jira/browse/CPPXT-44 --- xmltooling/soap/impl/CURLSOAPTransport.cpp | 15 +++++++++++---- xmltooling/util/CurlURLInputStream.cpp | 12 ++++++++---- xmltooling/util/CurlURLInputStream.h | 3 +++ 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/xmltooling/soap/impl/CURLSOAPTransport.cpp b/xmltooling/soap/impl/CURLSOAPTransport.cpp index 62d00e2..460a62e 100644 --- a/xmltooling/soap/impl/CURLSOAPTransport.cpp +++ b/xmltooling/soap/impl/CURLSOAPTransport.cpp @@ -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 > m_response_headers; + vector m_saved_options; #ifndef XMLTOOLING_NO_XMLSEC const OpenSSLCredential* m_cred; const OpenSSLTrustEngine* m_trustEngine; diff --git a/xmltooling/util/CurlURLInputStream.cpp b/xmltooling/util/CurlURLInputStream.cpp index f3b6dcd..2dbd77b 100644 --- a/xmltooling/util/CurlURLInputStream.cpp +++ b/xmltooling/util/CurlURLInputStream.cpp @@ -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()); diff --git a/xmltooling/util/CurlURLInputStream.h b/xmltooling/util/CurlURLInputStream.h index 6dfd02d..53b784f 100644 --- a/xmltooling/util/CurlURLInputStream.h +++ b/xmltooling/util/CurlURLInputStream.h @@ -26,6 +26,8 @@ #include +#include +#include #include #include @@ -100,6 +102,7 @@ namespace xmltooling { logging::Category& fLog; std::string fURL; + std::vector fSavedOptions; CURLM* fMulti; CURL* fEasy; -- 2.1.4