| 1 | // |
|---|---|
| 2 | // HTTPSSessionInstantiator.cpp |
| 3 | // |
| 4 | // Library: NetSSL_OpenSSL |
| 5 | // Package: HTTPSClient |
| 6 | // Module: HTTPSSessionInstantiator |
| 7 | // |
| 8 | // Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. |
| 9 | // and Contributors. |
| 10 | // |
| 11 | // SPDX-License-Identifier: BSL-1.0 |
| 12 | // |
| 13 | |
| 14 | |
| 15 | #include "Poco/Net/HTTPSSessionInstantiator.h" |
| 16 | #include "Poco/Net/HTTPSessionFactory.h" |
| 17 | #include "Poco/Net/HTTPSClientSession.h" |
| 18 | |
| 19 | |
| 20 | namespace Poco { |
| 21 | namespace Net { |
| 22 | |
| 23 | |
| 24 | HTTPSSessionInstantiator::HTTPSSessionInstantiator() |
| 25 | { |
| 26 | } |
| 27 | |
| 28 | |
| 29 | HTTPSSessionInstantiator::HTTPSSessionInstantiator(Context::Ptr pContext) : |
| 30 | _pContext(pContext) |
| 31 | { |
| 32 | } |
| 33 | |
| 34 | |
| 35 | HTTPSSessionInstantiator::~HTTPSSessionInstantiator() |
| 36 | { |
| 37 | } |
| 38 | |
| 39 | |
| 40 | HTTPClientSession* HTTPSSessionInstantiator::createClientSession(const Poco::URI& uri) |
| 41 | { |
| 42 | poco_assert (uri.getScheme() == "https"); |
| 43 | HTTPSClientSession* pSession = _pContext.isNull() ? new HTTPSClientSession(uri.getHost(), uri.getPort()) : new HTTPSClientSession(uri.getHost(), uri.getPort(), _pContext); |
| 44 | if (!proxyHost().empty()) |
| 45 | { |
| 46 | pSession->setProxy(proxyHost(), proxyPort()); |
| 47 | pSession->setProxyCredentials(proxyUsername(), proxyPassword()); |
| 48 | } |
| 49 | return pSession; |
| 50 | } |
| 51 | |
| 52 | |
| 53 | void HTTPSSessionInstantiator::registerInstantiator() |
| 54 | { |
| 55 | HTTPSessionFactory::defaultFactory().registerProtocol("https", new HTTPSSessionInstantiator); |
| 56 | } |
| 57 | |
| 58 | |
| 59 | void HTTPSSessionInstantiator::registerInstantiator(Context::Ptr context) |
| 60 | { |
| 61 | HTTPSessionFactory::defaultFactory().registerProtocol("https", new HTTPSSessionInstantiator(context)); |
| 62 | } |
| 63 | |
| 64 | |
| 65 | void HTTPSSessionInstantiator::unregisterInstantiator() |
| 66 | { |
| 67 | HTTPSessionFactory::defaultFactory().unregisterProtocol("https"); |
| 68 | } |
| 69 | |
| 70 | |
| 71 | } } // namespace Poco::Net |
| 72 |