mirror of
https://github.com/pocoproject/poco.git
synced 2025-03-04 07:27:23 +01:00
fixed GH #2549: Fix keepAlive in http client session
This commit is contained in:
parent
e5f49a898d
commit
2cd8950dfc
@ -110,47 +110,47 @@ public:
|
||||
///
|
||||
/// The host must not be changed once there is an
|
||||
/// open connection to the server.
|
||||
|
||||
|
||||
const std::string& getHost() const;
|
||||
/// Returns the host name of the target HTTP server.
|
||||
|
||||
|
||||
void setPort(Poco::UInt16 port);
|
||||
/// Sets the port number of the target HTTP server.
|
||||
///
|
||||
/// The port number must not be changed once there is an
|
||||
/// open connection to the server.
|
||||
|
||||
|
||||
Poco::UInt16 getPort() const;
|
||||
/// Returns the port number of the target HTTP server.
|
||||
|
||||
void setProxy(const std::string& host, Poco::UInt16 port = HTTPSession::HTTP_PORT);
|
||||
/// Sets the proxy host name and port number.
|
||||
|
||||
|
||||
void setProxyHost(const std::string& host);
|
||||
/// Sets the host name of the proxy server.
|
||||
|
||||
|
||||
void setProxyPort(Poco::UInt16 port);
|
||||
/// Sets the port number of the proxy server.
|
||||
|
||||
|
||||
const std::string& getProxyHost() const;
|
||||
/// Returns the proxy host name.
|
||||
|
||||
|
||||
Poco::UInt16 getProxyPort() const;
|
||||
/// Returns the proxy port number.
|
||||
|
||||
|
||||
void setProxyCredentials(const std::string& username, const std::string& password);
|
||||
/// Sets the username and password for proxy authentication.
|
||||
/// Only Basic authentication is supported.
|
||||
|
||||
|
||||
void setProxyUsername(const std::string& username);
|
||||
/// Sets the username for proxy authentication.
|
||||
/// Only Basic authentication is supported.
|
||||
|
||||
const std::string& getProxyUsername() const;
|
||||
/// Returns the username for proxy authentication.
|
||||
|
||||
|
||||
void setProxyPassword(const std::string& password);
|
||||
/// Sets the password for proxy authentication.
|
||||
/// Sets the password for proxy authentication.
|
||||
/// Only Basic authentication is supported.
|
||||
|
||||
const std::string& getProxyPassword() const;
|
||||
@ -177,10 +177,10 @@ public:
|
||||
|
||||
void setKeepAliveTimeout(const Poco::Timespan& timeout);
|
||||
/// Sets the connection timeout for HTTP connections.
|
||||
|
||||
|
||||
const Poco::Timespan& getKeepAliveTimeout() const;
|
||||
/// Returns the connection timeout for HTTP connections.
|
||||
|
||||
|
||||
virtual std::ostream& sendRequest(HTTPRequest& request);
|
||||
/// Sends the header for the given HTTP request to
|
||||
/// the server.
|
||||
@ -200,9 +200,9 @@ public:
|
||||
/// be reused and persistent connections are enabled
|
||||
/// to ensure a new connection will be set up
|
||||
/// for the next request.
|
||||
|
||||
|
||||
virtual std::istream& receiveResponse(HTTPResponse& response);
|
||||
/// Receives the header for the response to the previous
|
||||
/// Receives the header for the response to the previous
|
||||
/// HTTP request.
|
||||
///
|
||||
/// The returned input stream can be used to read
|
||||
@ -213,7 +213,7 @@ public:
|
||||
/// It must be ensured that the response stream
|
||||
/// is fully consumed before sending a new request
|
||||
/// and persistent connections are enabled. Otherwise,
|
||||
/// the unread part of the response body may be treated as
|
||||
/// the unread part of the response body may be treated as
|
||||
/// part of the next request's response header, resulting
|
||||
/// in a Poco::Net::MessageException being thrown.
|
||||
///
|
||||
@ -224,17 +224,17 @@ public:
|
||||
/// be reused and persistent connections are enabled
|
||||
/// to ensure a new connection will be set up
|
||||
/// for the next request.
|
||||
|
||||
|
||||
virtual bool peekResponse(HTTPResponse& response);
|
||||
/// If the request contains a "Expect: 100-continue" header,
|
||||
/// (see HTTPRequest::setExpectContinue()) this method can be
|
||||
/// used to check whether the server has sent a 100 Continue response
|
||||
/// (see HTTPRequest::setExpectContinue()) this method can be
|
||||
/// used to check whether the server has sent a 100 Continue response
|
||||
/// before continuing with the request, i.e. sending the request body,
|
||||
/// after calling sendRequest().
|
||||
///
|
||||
/// Returns true if the server has responded with 100 Continue,
|
||||
/// otherwise false. The HTTPResponse object contains the
|
||||
/// response sent by the server.
|
||||
/// response sent by the server.
|
||||
///
|
||||
/// In any case, receiveResponse() must be called afterwards as well in
|
||||
/// order to complete the request. The same HTTPResponse object
|
||||
@ -243,6 +243,14 @@ public:
|
||||
/// This method should only be called if the request contains
|
||||
/// a "Expect: 100-continue" header.
|
||||
|
||||
void flushRequest();
|
||||
/// Flushes the request stream.
|
||||
///
|
||||
/// Normally this method does not need to be called.
|
||||
/// It can be used to ensure the request has been
|
||||
/// fully sent if receiveResponse() is not called, e.g.,
|
||||
/// because the underlying socket will be detached.
|
||||
|
||||
void reset();
|
||||
/// Resets the session and closes the socket.
|
||||
///
|
||||
@ -254,11 +262,11 @@ public:
|
||||
/// or receiveResponse() throws an exception, or
|
||||
/// the request or response stream changes into
|
||||
/// fail or bad state, but not eof state).
|
||||
|
||||
|
||||
virtual bool secure() const;
|
||||
/// Return true iff the session uses SSL or TLS,
|
||||
/// or false otherwise.
|
||||
|
||||
|
||||
bool bypassProxy() const;
|
||||
/// Returns true if the proxy should be bypassed
|
||||
/// for the current host.
|
||||
@ -268,20 +276,20 @@ protected:
|
||||
{
|
||||
DEFAULT_KEEP_ALIVE_TIMEOUT = 8
|
||||
};
|
||||
|
||||
|
||||
void reconnect();
|
||||
/// Connects the underlying socket to the HTTP server.
|
||||
|
||||
int write(const char* buffer, std::streamsize length);
|
||||
/// Tries to re-connect if keep-alive is on.
|
||||
|
||||
|
||||
virtual std::string proxyRequestPrefix() const;
|
||||
/// Returns the prefix prepended to the URI for proxy requests
|
||||
/// (e.g., "http://myhost.com").
|
||||
|
||||
virtual bool mustReconnect() const;
|
||||
/// Checks if we can reuse a persistent connection.
|
||||
|
||||
|
||||
virtual void proxyAuthenticate(HTTPRequest& request);
|
||||
/// Sets the proxy credentials (Proxy-Authorization header), if
|
||||
/// proxy username and password have been set.
|
||||
@ -289,11 +297,11 @@ protected:
|
||||
void proxyAuthenticateImpl(HTTPRequest& request);
|
||||
/// Sets the proxy credentials (Proxy-Authorization header), if
|
||||
/// proxy username and password have been set.
|
||||
|
||||
|
||||
StreamSocket proxyConnect();
|
||||
/// Sends a CONNECT request to the proxy server and returns
|
||||
/// a StreamSocket for the resulting connection.
|
||||
|
||||
|
||||
void proxyTunnel();
|
||||
/// Calls proxyConnect() and attaches the resulting StreamSocket
|
||||
/// to the HTTPClientSession.
|
||||
@ -312,7 +320,7 @@ private:
|
||||
Poco::SharedPtr<std::istream> _pResponseStream;
|
||||
|
||||
static ProxyConfig _globalProxyConfig;
|
||||
|
||||
|
||||
HTTPClientSession(const HTTPClientSession&);
|
||||
HTTPClientSession& operator = (const HTTPClientSession&);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user