HTTPSStreamFactory.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. #ifndef NetSSL_HTTPSStreamFactory_INCLUDED
  16. #define NetSSL_HTTPSStreamFactory_INCLUDED
  17. #include "Poco/Net/NetSSL.h"
  18. #include "Poco/Net/HTTPSession.h"
  19. #include "Poco/URIStreamFactory.h"
  20. namespace Poco {
  21. namespace Net {
  22. class NetSSL_API HTTPSStreamFactory: public Poco::URIStreamFactory
  23. /// An implementation of the URIStreamFactory interface
  24. /// that handles secure Hyper-Text Transfer Protocol (https) URIs.
  25. {
  26. public:
  27. HTTPSStreamFactory();
  28. /// Creates the HTTPSStreamFactory.
  29. HTTPSStreamFactory(const std::string& proxyHost, Poco::UInt16 proxyPort = HTTPSession::HTTP_PORT);
  30. /// Creates the HTTPSStreamFactory.
  31. ///
  32. /// HTTPS connections will use the given proxy.
  33. HTTPSStreamFactory(const std::string& proxyHost, Poco::UInt16 proxyPort, const std::string& proxyUsername, const std::string& proxyPassword);
  34. /// Creates the HTTPSStreamFactory.
  35. ///
  36. /// HTTPS connections will use the given proxy and
  37. /// will be authorized against the proxy using Basic authentication
  38. /// with the given proxyUsername and proxyPassword.
  39. ~HTTPSStreamFactory();
  40. /// Destroys the HTTPSStreamFactory.
  41. std::istream* open(const Poco::URI& uri);
  42. /// Creates and opens a HTTPS stream for the given URI.
  43. /// The URI must be a https://... URI.
  44. ///
  45. /// Throws a NetException if anything goes wrong.
  46. static void registerFactory();
  47. /// Registers the HTTPSStreamFactory with the
  48. /// default URIStreamOpener instance.
  49. static void unregisterFactory();
  50. /// Unregisters the HTTPSStreamFactory with the
  51. /// default URIStreamOpener instance.
  52. private:
  53. enum
  54. {
  55. MAX_REDIRECTS = 10
  56. };
  57. std::string _proxyHost;
  58. Poco::UInt16 _proxyPort;
  59. std::string _proxyUsername;
  60. std::string _proxyPassword;
  61. };
  62. } } // namespace Poco::Net
  63. #endif // Net_HTTPSStreamFactory_INCLUDED