https://bugs.internet2.edu/jira/browse/CPPXT-27
authorcantor <cantor@de75baf8-a10c-0410-a50a-987c0e22f00f>
Tue, 28 Oct 2008 20:50:30 +0000 (20:50 +0000)
committercantor <cantor@de75baf8-a10c-0410-a50a-987c0e22f00f>
Tue, 28 Oct 2008 20:50:30 +0000 (20:50 +0000)
git-svn-id: https://svn.middleware.georgetown.edu/cpp-xmltooling/branches/REL_1@537 de75baf8-a10c-0410-a50a-987c0e22f00f

.cproject
xmltooling/security/impl/SecurityHelper.cpp
xmltooling/soap/SOAPTransport.h
xmltooling/soap/impl/CURLSOAPTransport.cpp
xmltooling/soap/impl/SOAPClient.cpp

index b78749e..895f74e 100644 (file)
--- a/.cproject
+++ b/.cproject
@@ -62,6 +62,7 @@
 <storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>\r
 \r
 \r
+<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>\r
 <storageModule moduleId="org.eclipse.cdt.core.pathentry">\r
 <pathentry include="C:/log4shib-1.0/include" kind="inc" path="" system="true"/>\r
 <pathentry include="C:/xerces-c_2_8_0-x86-windows-vc_8_0/include" kind="inc" path="" system="true"/>\r
@@ -76,6 +77,7 @@
 <pathentry kind="mac" name="WIN32" path="" value=""/>\r
 <pathentry kind="mac" name="XMLTOOL_API" path="" value=""/>\r
 <pathentry kind="mac" name="XMLTOOL_DLLLOCAL" path="" value=""/>\r
+<pathentry kind="mac" name="XMLTOOLING_LOGCAT" path="" value="&quot;XMLTooling&quot;"/>\r
 <pathentry kind="out" path="xmltooling/Debug"/>\r
 <pathentry kind="out" path="xmltoolingtest/Debug"/>\r
 <pathentry kind="out" path="debug"/>\r
index 5c39bf8..a562bb0 100644 (file)
@@ -344,13 +344,13 @@ vector<XSECCryptoX509CRL*>::size_type SecurityHelper::loadCRLsFromFile(
 XSECCryptoKey* SecurityHelper::loadKeyFromURL(SOAPTransport& transport, const char* backing, const char* format, const char* password)
 {
     // Fetch the data.
-    istringstream dummy;
-    transport.send(dummy);
+    transport.send();
     istream& msg = transport.receive();
 
     // Dump to output file.
     ofstream out(backing, fstream::trunc|fstream::binary);
     out << msg.rdbuf();
+    out.close();
 
     return loadKeyFromFile(backing, format, password);
 }
@@ -359,14 +359,13 @@ vector<XSECCryptoX509*>::size_type SecurityHelper::loadCertificatesFromURL(
     vector<XSECCryptoX509*>& certs, SOAPTransport& transport, const char* backing, const char* format, const char* password
     )
 {
-    // Fetch the data.
-    istringstream dummy;
-    transport.send(dummy);
+    transport.send();
     istream& msg = transport.receive();
 
     // Dump to output file.
     ofstream out(backing, fstream::trunc|fstream::binary);
     out << msg.rdbuf();
+    out.close();
 
     return loadCertificatesFromFile(certs, backing, format, password);
 }
@@ -376,13 +375,13 @@ vector<XSECCryptoX509CRL*>::size_type SecurityHelper::loadCRLsFromURL(
     )
 {
     // Fetch the data.
-    istringstream dummy;
-    transport.send(dummy);
+    transport.send();
     istream& msg = transport.receive();
 
     // Dump to output file.
     ofstream out(backing, fstream::trunc|fstream::binary);
     out << msg.rdbuf();
+    out.close();
 
     return loadCRLsFromFile(crls, backing, format);
 }
index ec6ed9c..b2e7ef3 100644 (file)
@@ -182,6 +182,17 @@ namespace xmltooling {
         virtual void send(std::istream& in)=0;
 
         /**
+         * Sends an optional stream of data over the transport. The function may return without
+         * having received any data, depending on the nature of the transport.
+         *
+         * <p>If the parameter is omitted, a request may be issued with no body if the transport
+         * supports that feature.
+         *
+         * @param in    input stream to send
+         */
+        virtual void send(std::istream* in=NULL);
+
+        /**
          * Returns reference to response stream.  The resulting stream must be
          * checked directly to determine whether data is available.
          *
index 41828dc..5e0a656 100644 (file)
@@ -166,7 +166,11 @@ namespace xmltooling {
 #endif
         }
 
-        void send(istream& in);
+        void send(istream& in) {
+            send(&in);
+        }
+
+        void send(istream* in=NULL);
 
         istream& receive() {
             return m_stream;
@@ -404,7 +408,7 @@ string CURLSOAPTransport::getContentType() const
     return content_type ? content_type : "";
 }
 
-void CURLSOAPTransport::send(istream& in)
+void CURLSOAPTransport::send(istream* in)
 {
 #ifdef _DEBUG
     xmltooling::NDC ndc("send");
@@ -428,13 +432,13 @@ void CURLSOAPTransport::send(istream& in)
         curl_easy_setopt(m_handle,CURLOPT_POST,1);
         m_headers=curl_slist_append(m_headers,"Transfer-Encoding: chunked");
         curl_easy_setopt(m_handle,CURLOPT_READFUNCTION,&curl_read_hook);
-        curl_easy_setopt(m_handle,CURLOPT_READDATA,&in);
+        curl_easy_setopt(m_handle,CURLOPT_READDATA,in);
     }
     else if (in) {
         char buf[1024];
-        while (in) {
-            in.read(buf,1024);
-            msg.append(buf,in.gcount());
+        while (*in) {
+            in->read(buf,1024);
+            msg.append(buf,in->gcount());
         }
         curl_easy_setopt(m_handle,CURLOPT_POST,1);
         curl_easy_setopt(m_handle,CURLOPT_READFUNCTION,NULL);
@@ -513,10 +517,10 @@ size_t xmltooling::curl_header_hook(void* ptr, size_t size, size_t nmemb, void*
 // callback to send data to server
 size_t xmltooling::curl_read_hook(void* ptr, size_t size, size_t nmemb, void* stream)
 {
-    // *stream is actually an istream object
-    istream& buf=*(reinterpret_cast<istream*>(stream));
-    buf.read(reinterpret_cast<char*>(ptr),size*nmemb);
-    return buf.gcount();
+    // stream is actually an istream pointer
+    istream* buf=reinterpret_cast<istream*>(stream);
+    buf->read(reinterpret_cast<char*>(ptr),size*nmemb);
+    return buf->gcount();
 }
 
 // callback to buffer data from server
index e89742b..7cf17f6 100644 (file)
@@ -35,6 +35,13 @@ using namespace xmltooling::logging;
 using namespace xmltooling;
 using namespace std;
 
+void SOAPTransport::send(istream* in)
+{
+    if (!in)
+        throw IOException("SOAP transport does not support an empty request body.");
+    return send(*in);
+}
+
 SOAPClient::~SOAPClient()
 {
     delete m_transport;