renamed canContinue() to peekResponse(), improved documentation

This commit is contained in:
Guenter Obiltschnig
2015-10-10 09:31:48 +02:00
parent b8811609fd
commit 754cb3b06e
4 changed files with 17 additions and 7 deletions

View File

@@ -227,19 +227,20 @@ public:
/// to ensure a new connection will be set up
/// for the next request.
virtual bool canContinue(HTTPResponse& response);
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
/// 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,
/// otherwise false. The HTTPResponse object contains the
/// 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
/// 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
/// a "Expect: 100-continue" header.

View File

@@ -52,6 +52,15 @@ public:
/// Must be overridden by subclasses.
///
/// 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:
Poco::BasicEvent<const bool> serverStopped;

View File

@@ -307,7 +307,7 @@ std::istream& HTTPClientSession::receiveResponse(HTTPResponse& response)
}
bool HTTPClientSession::canContinue(HTTPResponse& response)
bool HTTPClientSession::peekResponse(HTTPResponse& response)
{
poco_assert (!_responseReceived);

View File

@@ -310,7 +310,7 @@ void HTTPClientSessionTest::testExpectContinue()
request.setExpectContinue(true);
s.sendRequest(request) << body;
HTTPResponse response;
assert (s.canContinue(response));
assert (s.peekResponse(response));
assert (response.getStatus() == HTTPResponse::HTTP_CONTINUE);
std::istream& rs = s.receiveResponse(response);
assert (response.getStatus() == HTTPResponse::HTTP_OK);
@@ -331,7 +331,7 @@ void HTTPClientSessionTest::testExpectContinueFail()
request.setExpectContinue(true);
s.sendRequest(request) << body;
HTTPResponse response;
assert (!s.canContinue(response));
assert (!s.peekResponse(response));
assert (response.getStatus() == HTTPResponse::HTTP_BAD_REQUEST);
std::istream& rs = s.receiveResponse(response);
assert (response.getStatus() == HTTPResponse::HTTP_BAD_REQUEST);