https://bugs.internet2.edu/jira/browse/CPPXT-56
[shibboleth/xmltooling.git] / xmltooling / util / CurlURLInputStream.h
index e397331..3adf169 100644 (file)
@@ -26,6 +26,8 @@
 
 #include <xmltooling/logging.h>
 
+#include <string>
+#include <vector>
 #include <curl/curl.h>
 #include <xercesc/util/BinInputStream.hpp>
 
@@ -41,16 +43,18 @@ namespace xmltooling {
         /**
          * Constructor.
          *
-         * @param url   the URL of the resource to fetch
+         * @param url       the URL of the resource to fetch
+         * @param cacheTag  optional pointer to string used for cache management
          */
-        CurlURLInputStream(const char* url);
+        CurlURLInputStream(const char* url, std::string* cacheTag=NULL);
 
         /**
          * Constructor.
          *
-         * @param url   the URL of the resource to fetch
+         * @param url       the URL of the resource to fetch
+         * @param cacheTag  optional pointer to string used for cache management
          */
-        CurlURLInputStream(const XMLCh* url);
+        CurlURLInputStream(const XMLCh* url, std::string* cacheTag=NULL);
 
         /**
          * Constructor taking a DOM element supporting the following content:
@@ -64,9 +68,10 @@ namespace xmltooling {
          *  <dd>&lt;TransportOption provider="CURL" option="150"&gt;0&lt;/TransportOption&gt;</dd>
          * </dl>
          * 
-         * @param e     DOM to supply configuration
+         * @param e         DOM to supply configuration
+         * @param cacheTag  optional pointer to string used for cache management
          */
-        CurlURLInputStream(const xercesc::DOMElement* e);
+        CurlURLInputStream(const xercesc::DOMElement* e, std::string* cacheTag=NULL);
 
         ~CurlURLInputStream();
 
@@ -87,6 +92,15 @@ namespace xmltooling {
 
         xsecsize_t readBytes(XMLByte* const toFill, const xsecsize_t maxToRead);
 
+        /**
+         * Access the OpenSSL context options in place for this object.
+         *
+         * @return bitmask suitable for use with SSL_CTX_set_options
+         */
+        int getOpenSSLOps() const {
+            return fOpenSSLOps;
+        }
+
     private :
         CurlURLInputStream(const CurlURLInputStream&);
         CurlURLInputStream& operator=(const CurlURLInputStream&);
@@ -98,11 +112,15 @@ namespace xmltooling {
         void init(const xercesc::DOMElement* e=NULL);
         bool readMore(int *runningHandles);
 
-        logging::Category&  fLog;\r
-        std::string         fURL;\r
+        logging::Category&  fLog;
+        std::string*        fCacheTag;
+        std::string         fURL;
+        std::vector<std::string>    fSavedOptions;
+        int                 fOpenSSLOps;
 
         CURLM*              fMulti;
         CURL*               fEasy;
+        struct curl_slist*  fHeaders;
 
         unsigned long       fTotalBytesRead;
         XMLByte*            fWritePtr;
@@ -117,6 +135,7 @@ namespace xmltooling {
         XMLByte*            fBufferTailPtr;
 
         XMLCh*              fContentType;
+        long                fStatusCode;
 
         char                fError[CURL_ERROR_SIZE];
     };