mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-28 19:51:58 +01:00
#3089: HTTPSessionFactory does not support HTTPClientSession::ProxyConfig
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
|
||||
|
||||
#include "Poco/Net/Net.h"
|
||||
#include "Poco/Net/HTTPClientSession.h"
|
||||
#include "Poco/Mutex.h"
|
||||
#include "Poco/URI.h"
|
||||
#include "Poco/SingletonHolder.h"
|
||||
@@ -31,7 +32,6 @@ namespace Net {
|
||||
|
||||
|
||||
class HTTPSessionInstantiator;
|
||||
class HTTPClientSession;
|
||||
|
||||
|
||||
class Net_API HTTPSessionFactory
|
||||
@@ -52,6 +52,9 @@ public:
|
||||
HTTPSessionFactory(const std::string& proxyHost, Poco::UInt16 proxyPort);
|
||||
/// Creates the HTTPSessionFactory and sets the proxy host and port.
|
||||
|
||||
HTTPSessionFactory(const HTTPClientSession::ProxyConfig& proxyConfig);
|
||||
/// Creates the HTTPSessionFactory and sets the proxy configuration.
|
||||
|
||||
~HTTPSessionFactory();
|
||||
/// Destroys the HTTPSessionFactory.
|
||||
|
||||
@@ -78,22 +81,28 @@ public:
|
||||
|
||||
const std::string& proxyHost() const;
|
||||
/// Returns the proxy host, if one has been set, or an empty string otherwise.
|
||||
|
||||
|
||||
Poco::UInt16 proxyPort() const;
|
||||
/// Returns the proxy port number, if one has been set, or zero otherwise.
|
||||
|
||||
void setProxy(const std::string& proxyHost, Poco::UInt16 proxyPort);
|
||||
/// Sets the proxy host and port number.
|
||||
|
||||
|
||||
void setProxyCredentials(const std::string& username, const std::string& password);
|
||||
/// Sets the username and password for proxy authorization (Basic auth only).
|
||||
|
||||
const std::string& proxyUsername() const;
|
||||
/// Returns the username for proxy authorization.
|
||||
|
||||
|
||||
const std::string& proxyPassword() const;
|
||||
/// Returns the password for proxy authorization.
|
||||
|
||||
void setProxyConfig(const HTTPClientSession::ProxyConfig& proxyConfig);
|
||||
/// Sets the proxy configuration.
|
||||
|
||||
const HTTPClientSession::ProxyConfig& getProxyConfig() const;
|
||||
/// Returns the proxy configuration.
|
||||
|
||||
static HTTPSessionFactory& defaultFactory();
|
||||
/// Returns the default HTTPSessionFactory.
|
||||
|
||||
@@ -109,14 +118,11 @@ private:
|
||||
|
||||
HTTPSessionFactory(const HTTPSessionFactory&);
|
||||
HTTPSessionFactory& operator = (const HTTPSessionFactory&);
|
||||
|
||||
|
||||
typedef std::map<std::string, InstantiatorInfo> Instantiators;
|
||||
|
||||
Instantiators _instantiators;
|
||||
std::string _proxyHost;
|
||||
Poco::UInt16 _proxyPort;
|
||||
std::string _proxyUsername;
|
||||
std::string _proxyPassword;
|
||||
HTTPClientSession::ProxyConfig _proxyConfig;
|
||||
|
||||
mutable Poco::FastMutex _mutex;
|
||||
};
|
||||
@@ -127,25 +133,31 @@ private:
|
||||
//
|
||||
inline const std::string& HTTPSessionFactory::proxyHost() const
|
||||
{
|
||||
return _proxyHost;
|
||||
return _proxyConfig.host;
|
||||
}
|
||||
|
||||
|
||||
inline Poco::UInt16 HTTPSessionFactory::proxyPort() const
|
||||
{
|
||||
return _proxyPort;
|
||||
return _proxyConfig.port;
|
||||
}
|
||||
|
||||
|
||||
inline const std::string& HTTPSessionFactory::proxyUsername() const
|
||||
{
|
||||
return _proxyUsername;
|
||||
return _proxyConfig.username;
|
||||
}
|
||||
|
||||
|
||||
inline const std::string& HTTPSessionFactory::proxyPassword() const
|
||||
{
|
||||
return _proxyPassword;
|
||||
return _proxyConfig.password;
|
||||
}
|
||||
|
||||
|
||||
inline const HTTPClientSession::ProxyConfig& HTTPSessionFactory::getProxyConfig() const
|
||||
{
|
||||
return _proxyConfig;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
|
||||
#include "Poco/Net/Net.h"
|
||||
#include "Poco/Net/HTTPSession.h"
|
||||
#include "Poco/Net/HTTPClientSession.h"
|
||||
#include "Poco/URI.h"
|
||||
|
||||
|
||||
@@ -27,9 +27,6 @@ namespace Poco {
|
||||
namespace Net {
|
||||
|
||||
|
||||
class HTTPClientSession;
|
||||
|
||||
|
||||
class Net_API HTTPSessionInstantiator
|
||||
/// A factory for HTTPClientSession objects.
|
||||
///
|
||||
@@ -55,31 +52,15 @@ public:
|
||||
/// Unregisters the factory with the global HTTPSessionFactory.
|
||||
|
||||
protected:
|
||||
void setProxy(const std::string& host, Poco::UInt16 port);
|
||||
/// Sets the proxy host and port.
|
||||
/// Called by HTTPSessionFactory.
|
||||
|
||||
const std::string& proxyHost() const;
|
||||
/// Returns the proxy post.
|
||||
void setProxyConfig(const HTTPClientSession::ProxyConfig& proxyConfig);
|
||||
/// Sets the proxy configuration.
|
||||
|
||||
Poco::UInt16 proxyPort() const;
|
||||
/// Returns the proxy port.
|
||||
|
||||
void setProxyCredentials(const std::string& username, const std::string& password);
|
||||
/// Sets the username and password for proxy authorization (Basic auth only).
|
||||
|
||||
const std::string& proxyUsername() const;
|
||||
/// Returns the username for proxy authorization.
|
||||
|
||||
const std::string& proxyPassword() const;
|
||||
/// Returns the password for proxy authorization.
|
||||
const HTTPClientSession::ProxyConfig& getProxyConfig() const;
|
||||
/// Returns the proxy configuration.
|
||||
|
||||
private:
|
||||
std::string _proxyHost;
|
||||
Poco::UInt16 _proxyPort;
|
||||
std::string _proxyUsername;
|
||||
std::string _proxyPassword;
|
||||
|
||||
HTTPClientSession::ProxyConfig _proxyConfig;
|
||||
|
||||
friend class HTTPSessionFactory;
|
||||
};
|
||||
|
||||
@@ -87,27 +68,9 @@ private:
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline const std::string& HTTPSessionInstantiator::proxyHost() const
|
||||
inline const HTTPClientSession::ProxyConfig& HTTPSessionInstantiator::getProxyConfig() const
|
||||
{
|
||||
return _proxyHost;
|
||||
}
|
||||
|
||||
|
||||
inline Poco::UInt16 HTTPSessionInstantiator::proxyPort() const
|
||||
{
|
||||
return _proxyPort;
|
||||
}
|
||||
|
||||
|
||||
inline const std::string& HTTPSessionInstantiator::proxyUsername() const
|
||||
{
|
||||
return _proxyUsername;
|
||||
}
|
||||
|
||||
|
||||
inline const std::string& HTTPSessionInstantiator::proxyPassword() const
|
||||
{
|
||||
return _proxyPassword;
|
||||
return _proxyConfig;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user