| 1 | // |
| 2 | // HTTPSStreamFactory.h |
| 3 | // |
| 4 | // Library: NetSSL_OpenSSL |
| 5 | // Package: HTTPSClient |
| 6 | // Module: HTTPSStreamFactory |
| 7 | // |
| 8 | // Definition of the HTTPSStreamFactory class. |
| 9 | // |
| 10 | // Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. |
| 11 | // and Contributors. |
| 12 | // |
| 13 | // SPDX-License-Identifier: BSL-1.0 |
| 14 | // |
| 15 | |
| 16 | |
| 17 | #ifndef NetSSL_HTTPSStreamFactory_INCLUDED |
| 18 | #define NetSSL_HTTPSStreamFactory_INCLUDED |
| 19 | |
| 20 | |
| 21 | #include "Poco/Net/NetSSL.h" |
| 22 | #include "Poco/Net/HTTPSession.h" |
| 23 | #include "Poco/URIStreamFactory.h" |
| 24 | |
| 25 | |
| 26 | namespace Poco { |
| 27 | namespace Net { |
| 28 | |
| 29 | |
| 30 | class NetSSL_API HTTPSStreamFactory: public Poco::URIStreamFactory |
| 31 | /// An implementation of the URIStreamFactory interface |
| 32 | /// that handles secure Hyper-Text Transfer Protocol (https) URIs. |
| 33 | { |
| 34 | public: |
| 35 | HTTPSStreamFactory(); |
| 36 | /// Creates the HTTPSStreamFactory. |
| 37 | |
| 38 | HTTPSStreamFactory(const std::string& proxyHost, Poco::UInt16 proxyPort = HTTPSession::HTTP_PORT); |
| 39 | /// Creates the HTTPSStreamFactory. |
| 40 | /// |
| 41 | /// HTTPS connections will use the given proxy. |
| 42 | |
| 43 | HTTPSStreamFactory(const std::string& proxyHost, Poco::UInt16 proxyPort, const std::string& proxyUsername, const std::string& proxyPassword); |
| 44 | /// Creates the HTTPSStreamFactory. |
| 45 | /// |
| 46 | /// HTTPS connections will use the given proxy and |
| 47 | /// will be authorized against the proxy using Basic authentication |
| 48 | /// with the given proxyUsername and proxyPassword. |
| 49 | |
| 50 | ~HTTPSStreamFactory(); |
| 51 | /// Destroys the HTTPSStreamFactory. |
| 52 | |
| 53 | std::istream* open(const Poco::URI& uri); |
| 54 | /// Creates and opens a HTTPS stream for the given URI. |
| 55 | /// The URI must be a https://... URI. |
| 56 | /// |
| 57 | /// Throws a NetException if anything goes wrong. |
| 58 | |
| 59 | static void registerFactory(); |
| 60 | /// Registers the HTTPSStreamFactory with the |
| 61 | /// default URIStreamOpener instance. |
| 62 | |
| 63 | static void unregisterFactory(); |
| 64 | /// Unregisters the HTTPSStreamFactory with the |
| 65 | /// default URIStreamOpener instance. |
| 66 | |
| 67 | private: |
| 68 | enum |
| 69 | { |
| 70 | MAX_REDIRECTS = 10 |
| 71 | }; |
| 72 | |
| 73 | std::string _proxyHost; |
| 74 | Poco::UInt16 _proxyPort; |
| 75 | std::string _proxyUsername; |
| 76 | std::string _proxyPassword; |
| 77 | }; |
| 78 | |
| 79 | |
| 80 | } } // namespace Poco::Net |
| 81 | |
| 82 | |
| 83 | #endif // Net_HTTPSStreamFactory_INCLUDED |
| 84 | |