diff --git a/NetSSL_OpenSSL/include/Poco/Net/HTTPSSessionInstantiator.h b/NetSSL_OpenSSL/include/Poco/Net/HTTPSSessionInstantiator.h index 67069adb4..858eb4268 100644 --- a/NetSSL_OpenSSL/include/Poco/Net/HTTPSSessionInstantiator.h +++ b/NetSSL_OpenSSL/include/Poco/Net/HTTPSSessionInstantiator.h @@ -1,7 +1,7 @@ // // HTTPSSessionInstantiator.h // -// $Id: //poco/1.4/NetSSL_OpenSSL/include/Poco/Net/HTTPSSessionInstantiator.h#1 $ +// $Id: //poco/1.4/NetSSL_OpenSSL/include/Poco/Net/HTTPSSessionInstantiator.h#2 $ // // Library: NetSSL_OpenSSL // Package: HTTPSClient @@ -41,6 +41,7 @@ #include "Poco/Net/NetSSL.h" +#include "Poco/Net/Context.h" #include "Poco/Net/Utility.h" #include "Poco/Net/HTTPSessionInstantiator.h" #include "Poco/URI.h" @@ -57,6 +58,9 @@ public: HTTPSSessionInstantiator(); /// Creates the HTTPSSessionInstantiator. + HTTPSSessionInstantiator(Context::Ptr pContext); + /// Creates the HTTPSSessionInstantiator using the given SSL context. + ~HTTPSSessionInstantiator(); /// Destroys the HTTPSSessionInstantiator. @@ -66,8 +70,14 @@ public: static void registerInstantiator(); /// Registers the instantiator with the global HTTPSessionFactory. + static void registerInstantiator(Context::Ptr pContext); + /// Registers the instantiator with the global HTTPSessionFactory using the given SSL context. + static void unregisterInstantiator(); /// Unregisters the factory with the global HTTPSessionFactory. + +private: + Context::Ptr _pContext; }; diff --git a/NetSSL_OpenSSL/src/HTTPSSessionInstantiator.cpp b/NetSSL_OpenSSL/src/HTTPSSessionInstantiator.cpp index d19370703..7eef65202 100644 --- a/NetSSL_OpenSSL/src/HTTPSSessionInstantiator.cpp +++ b/NetSSL_OpenSSL/src/HTTPSSessionInstantiator.cpp @@ -1,7 +1,7 @@ // // HTTPSSessionInstantiator.cpp // -// $Id: //poco/1.4/NetSSL_OpenSSL/src/HTTPSSessionInstantiator.cpp#1 $ +// $Id: //poco/1.4/NetSSL_OpenSSL/src/HTTPSSessionInstantiator.cpp#2 $ // // Library: NetSSL_OpenSSL // Package: HTTPSClient @@ -48,6 +48,12 @@ HTTPSSessionInstantiator::HTTPSSessionInstantiator() } +HTTPSSessionInstantiator::HTTPSSessionInstantiator(Context::Ptr pContext) : + _pContext(pContext) +{ +} + + HTTPSSessionInstantiator::~HTTPSSessionInstantiator() { } @@ -56,7 +62,7 @@ HTTPSSessionInstantiator::~HTTPSSessionInstantiator() HTTPClientSession* HTTPSSessionInstantiator::createClientSession(const Poco::URI& uri) { poco_assert (uri.getScheme() == "https"); - HTTPSClientSession* pSession = new HTTPSClientSession(uri.getHost(), uri.getPort()); + HTTPSClientSession* pSession = _pContext.isNull() ? new HTTPSClientSession(uri.getHost(), uri.getPort()) : new HTTPSClientSession(uri.getHost(), uri.getPort(), _pContext); pSession->setProxy(proxyHost(), proxyPort()); pSession->setProxyCredentials(proxyUsername(), proxyPassword()); return pSession; @@ -69,6 +75,12 @@ void HTTPSSessionInstantiator::registerInstantiator() } +void HTTPSSessionInstantiator::registerInstantiator(Context::Ptr context) +{ + HTTPSessionFactory::defaultFactory().registerProtocol("https", new HTTPSSessionInstantiator(context)); +} + + void HTTPSSessionInstantiator::unregisterInstantiator() { HTTPSessionFactory::defaultFactory().unregisterProtocol("https");