mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-28 11:31:53 +01:00
renamed canContinue() to peekResponse(), improved documentation
This commit is contained in:
@@ -227,19 +227,20 @@ public:
|
|||||||
/// to ensure a new connection will be set up
|
/// to ensure a new connection will be set up
|
||||||
/// for the next request.
|
/// for the next request.
|
||||||
|
|
||||||
virtual bool canContinue(HTTPResponse& response);
|
virtual bool peekResponse(HTTPResponse& response);
|
||||||
/// If the request contains a "Expect: 100-continue" header,
|
/// If the request contains a "Expect: 100-continue" header,
|
||||||
/// (see HTTPRequest::setExpectContinue()) this method can be
|
/// (see HTTPRequest::setExpectContinue()) this method can be
|
||||||
/// used to check whether the server has sent a 100 Continue response
|
/// used to check whether the server has sent a 100 Continue response
|
||||||
/// before continuing with the request, i.e. sending the request body.
|
/// before continuing with the request, i.e. sending the request body,
|
||||||
|
/// after calling sendRequest().
|
||||||
///
|
///
|
||||||
/// Returns true if the server has responded with 100 Continue,
|
/// Returns true if the server has responded with 100 Continue,
|
||||||
/// otherwise false. The HTTPResponse object contains the
|
/// otherwise false. The HTTPResponse object contains the
|
||||||
/// response sent by the server.
|
/// response sent by the server.
|
||||||
///
|
///
|
||||||
/// In any case, receiveResponse() must be called as well in
|
/// In any case, receiveResponse() must be called afterwards as well in
|
||||||
/// order to complete the request. The same HTTPResponse object
|
/// order to complete the request. The same HTTPResponse object
|
||||||
/// passed to canContinue() must also be passed to receiveResponse().
|
/// passed to peekResponse() must also be passed to receiveResponse().
|
||||||
///
|
///
|
||||||
/// This method should only be called if the request contains
|
/// This method should only be called if the request contains
|
||||||
/// a "Expect: 100-continue" header.
|
/// a "Expect: 100-continue" header.
|
||||||
|
|||||||
@@ -52,6 +52,15 @@ public:
|
|||||||
/// Must be overridden by subclasses.
|
/// Must be overridden by subclasses.
|
||||||
///
|
///
|
||||||
/// Creates a new request handler for the given HTTP request.
|
/// Creates a new request handler for the given HTTP request.
|
||||||
|
///
|
||||||
|
/// The method should inspect the given HTTPServerRequest object (e.g., method
|
||||||
|
/// and URI) and create an appropriate HTTPRequestHandler object to handle the
|
||||||
|
/// request.
|
||||||
|
///
|
||||||
|
/// If the request contains a "Expect: 100-continue" header, it's possible
|
||||||
|
/// to prevent the server from sending the default 100 Continue response
|
||||||
|
/// by setting the status of the response object that can be obtained through
|
||||||
|
/// the request object (request.response()) to something other than 200 OK.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Poco::BasicEvent<const bool> serverStopped;
|
Poco::BasicEvent<const bool> serverStopped;
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ std::istream& HTTPClientSession::receiveResponse(HTTPResponse& response)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool HTTPClientSession::canContinue(HTTPResponse& response)
|
bool HTTPClientSession::peekResponse(HTTPResponse& response)
|
||||||
{
|
{
|
||||||
poco_assert (!_responseReceived);
|
poco_assert (!_responseReceived);
|
||||||
|
|
||||||
|
|||||||
@@ -310,7 +310,7 @@ void HTTPClientSessionTest::testExpectContinue()
|
|||||||
request.setExpectContinue(true);
|
request.setExpectContinue(true);
|
||||||
s.sendRequest(request) << body;
|
s.sendRequest(request) << body;
|
||||||
HTTPResponse response;
|
HTTPResponse response;
|
||||||
assert (s.canContinue(response));
|
assert (s.peekResponse(response));
|
||||||
assert (response.getStatus() == HTTPResponse::HTTP_CONTINUE);
|
assert (response.getStatus() == HTTPResponse::HTTP_CONTINUE);
|
||||||
std::istream& rs = s.receiveResponse(response);
|
std::istream& rs = s.receiveResponse(response);
|
||||||
assert (response.getStatus() == HTTPResponse::HTTP_OK);
|
assert (response.getStatus() == HTTPResponse::HTTP_OK);
|
||||||
@@ -331,7 +331,7 @@ void HTTPClientSessionTest::testExpectContinueFail()
|
|||||||
request.setExpectContinue(true);
|
request.setExpectContinue(true);
|
||||||
s.sendRequest(request) << body;
|
s.sendRequest(request) << body;
|
||||||
HTTPResponse response;
|
HTTPResponse response;
|
||||||
assert (!s.canContinue(response));
|
assert (!s.peekResponse(response));
|
||||||
assert (response.getStatus() == HTTPResponse::HTTP_BAD_REQUEST);
|
assert (response.getStatus() == HTTPResponse::HTTP_BAD_REQUEST);
|
||||||
std::istream& rs = s.receiveResponse(response);
|
std::istream& rs = s.receiveResponse(response);
|
||||||
assert (response.getStatus() == HTTPResponse::HTTP_BAD_REQUEST);
|
assert (response.getStatus() == HTTPResponse::HTTP_BAD_REQUEST);
|
||||||
|
|||||||
Reference in New Issue
Block a user