X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fcpp-xmltooling.git;a=blobdiff_plain;f=xmltooling%2Fsoap%2Fimpl%2FCURLSOAPTransport.cpp;h=da8a3f54174d5e37dc9581864f2bb3e19b65ea06;hp=8b2aad31b845122fd115ae30ec9c53e134aeeed4;hb=c7288a45e5a581ea8253cf4c1d45e84281172584;hpb=36769dc1d8419136e55dde51697b47683b376214 diff --git a/xmltooling/soap/impl/CURLSOAPTransport.cpp b/xmltooling/soap/impl/CURLSOAPTransport.cpp index 8b2aad3..da8a3f5 100644 --- a/xmltooling/soap/impl/CURLSOAPTransport.cpp +++ b/xmltooling/soap/impl/CURLSOAPTransport.cpp @@ -77,6 +77,7 @@ namespace xmltooling { curl_easy_setopt(m_handle,CURLOPT_HTTPAUTH,0); curl_easy_setopt(m_handle,CURLOPT_USERPWD,NULL); curl_easy_setopt(m_handle,CURLOPT_HEADERDATA,this); + m_headers=curl_slist_append(m_headers,"Content-Type: text/xml"); } virtual ~CURLSOAPTransport() { @@ -117,7 +118,11 @@ namespace xmltooling { return true; } - size_t send(istream& in, ostream& out); + void send(istream& in); + + istream& receive() { + return m_stream; + } string getContentType() const; @@ -141,6 +146,7 @@ namespace xmltooling { const KeyInfoSource& m_peer; string m_endpoint; CURL* m_handle; + stringstream m_stream; mutable struct curl_slist* m_headers; map > m_response_headers; mutable const OpenSSLCredentialResolver* m_credResolver; @@ -325,7 +331,7 @@ string CURLSOAPTransport::getContentType() const return content_type ? content_type : ""; } -size_t CURLSOAPTransport::send(istream& in, ostream& out) +void CURLSOAPTransport::send(istream& in) { #ifdef _DEBUG xmltooling::NDC ndc("send"); @@ -337,11 +343,9 @@ size_t CURLSOAPTransport::send(istream& in, ostream& out) // caller should have executed any set functions to manipulate it. // Setup standard per-call curl properties. - size_t content_length=0; - pair output = make_pair(&out,&content_length); curl_easy_setopt(m_handle,CURLOPT_POST,1); curl_easy_setopt(m_handle,CURLOPT_READDATA,&in); - curl_easy_setopt(m_handle,CURLOPT_FILE,&output); + curl_easy_setopt(m_handle,CURLOPT_FILE,&m_stream); curl_easy_setopt(m_handle,CURLOPT_DEBUGDATA,&log_curl); char curl_errorbuf[CURL_ERROR_SIZE]; @@ -374,8 +378,6 @@ size_t CURLSOAPTransport::send(istream& in, ostream& out) string("CURLSOAPTransport::send() failed while contacting SOAP responder: ") + (curl_errorbuf[0] ? curl_errorbuf : "no further information available")); } - - return content_length; } // callback to buffer headers from server @@ -417,10 +419,8 @@ size_t xmltooling::curl_read_hook(void* ptr, size_t size, size_t nmemb, void* st // callback to buffer data from server size_t xmltooling::curl_write_hook(void* ptr, size_t size, size_t nmemb, void* stream) { - pair* output = reinterpret_cast*>(stream); size_t len = size*nmemb; - output->first->write(reinterpret_cast(ptr),len); - *(output->second) += len; + reinterpret_cast(stream)->write(reinterpret_cast(ptr),len); return len; }