Skip to content

Commit a628c56

Browse files
committed
- Poco::Net::HTTPSSessionInstantiator::registerInstantiator() now optionally accepts a Poco::Net::Context object.
1 parent e36800c commit a628c56

2 files changed

Lines changed: 25 additions & 3 deletions

File tree

‎NetSSL_OpenSSL/include/Poco/Net/HTTPSSessionInstantiator.h‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// HTTPSSessionInstantiator.h
33
//
4-
// $Id: //poco/1.4/NetSSL_OpenSSL/include/Poco/Net/HTTPSSessionInstantiator.h#1 $
4+
// $Id: //poco/1.4/NetSSL_OpenSSL/include/Poco/Net/HTTPSSessionInstantiator.h#2 $
55
//
66
// Library: NetSSL_OpenSSL
77
// Package: HTTPSClient
@@ -41,6 +41,7 @@
4141

4242

4343
#include "Poco/Net/NetSSL.h"
44+
#include "Poco/Net/Context.h"
4445
#include "Poco/Net/Utility.h"
4546
#include "Poco/Net/HTTPSessionInstantiator.h"
4647
#include "Poco/URI.h"
@@ -57,6 +58,9 @@ class NetSSL_API HTTPSSessionInstantiator: public HTTPSessionInstantiator
5758
HTTPSSessionInstantiator();
5859
/// Creates the HTTPSSessionInstantiator.
5960

61+
HTTPSSessionInstantiator(Context::Ptr pContext);
62+
/// Creates the HTTPSSessionInstantiator using the given SSL context.
63+
6064
~HTTPSSessionInstantiator();
6165
/// Destroys the HTTPSSessionInstantiator.
6266

@@ -66,8 +70,14 @@ class NetSSL_API HTTPSSessionInstantiator: public HTTPSessionInstantiator
6670
static void registerInstantiator();
6771
/// Registers the instantiator with the global HTTPSessionFactory.
6872

73+
static void registerInstantiator(Context::Ptr pContext);
74+
/// Registers the instantiator with the global HTTPSessionFactory using the given SSL context.
75+
6976
static void unregisterInstantiator();
7077
/// Unregisters the factory with the global HTTPSessionFactory.
78+
79+
private:
80+
Context::Ptr _pContext;
7181
};
7282

7383

‎NetSSL_OpenSSL/src/HTTPSSessionInstantiator.cpp‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// HTTPSSessionInstantiator.cpp
33
//
4-
// $Id: //poco/1.4/NetSSL_OpenSSL/src/HTTPSSessionInstantiator.cpp#1 $
4+
// $Id: //poco/1.4/NetSSL_OpenSSL/src/HTTPSSessionInstantiator.cpp#2 $
55
//
66
// Library: NetSSL_OpenSSL
77
// Package: HTTPSClient
@@ -48,6 +48,12 @@ HTTPSSessionInstantiator::HTTPSSessionInstantiator()
4848
}
4949

5050

51+
HTTPSSessionInstantiator::HTTPSSessionInstantiator(Context::Ptr pContext) :
52+
_pContext(pContext)
53+
{
54+
}
55+
56+
5157
HTTPSSessionInstantiator::~HTTPSSessionInstantiator()
5258
{
5359
}
@@ -56,7 +62,7 @@ HTTPSSessionInstantiator::~HTTPSSessionInstantiator()
5662
HTTPClientSession* HTTPSSessionInstantiator::createClientSession(const Poco::URI& uri)
5763
{
5864
poco_assert (uri.getScheme() == "https");
59-
HTTPSClientSession* pSession = new HTTPSClientSession(uri.getHost(), uri.getPort());
65+
HTTPSClientSession* pSession = _pContext.isNull() ? new HTTPSClientSession(uri.getHost(), uri.getPort()) : new HTTPSClientSession(uri.getHost(), uri.getPort(), _pContext);
6066
pSession->setProxy(proxyHost(), proxyPort());
6167
pSession->setProxyCredentials(proxyUsername(), proxyPassword());
6268
return pSession;
@@ -69,6 +75,12 @@ void HTTPSSessionInstantiator::registerInstantiator()
6975
}
7076

7177

78+
void HTTPSSessionInstantiator::registerInstantiator(Context::Ptr context)
79+
{
80+
HTTPSessionFactory::defaultFactory().registerProtocol("https", new HTTPSSessionInstantiator(context));
81+
}
82+
83+
7284
void HTTPSSessionInstantiator::unregisterInstantiator()
7385
{
7486
HTTPSessionFactory::defaultFactory().unregisterProtocol("https");

0 commit comments

Comments
 (0)