porting rev.1894 to trunk

This commit is contained in:
Aleksandar Fabijanic
2012-07-27 02:01:39 +00:00
parent 348ca08e7a
commit 03ddca58f5
13 changed files with 168 additions and 46 deletions

View File

@@ -223,11 +223,15 @@ std::ostream& HTTPClientSession::sendRequest(HTTPRequest& request)
request.write(hos);
_pRequestStream = new HTTPChunkedOutputStream(*this);
}
else if (request.getContentLength() != HTTPMessage::UNKNOWN_CONTENT_LENGTH)
else if (request.hasContentLength())
{
Poco::CountingOutputStream cs;
request.write(cs);
#if POCO_HAVE_INT64
_pRequestStream = new HTTPFixedLengthOutputStream(*this, request.getContentLength64() + cs.chars());
#else
_pRequestStream = new HTTPFixedLengthOutputStream(*this, request.getContentLength() + cs.chars());
#endif
request.write(*_pRequestStream);
}
else if (request.getMethod() != HTTPRequest::HTTP_PUT && request.getMethod() != HTTPRequest::HTTP_POST)
@@ -284,12 +288,16 @@ std::istream& HTTPClientSession::receiveResponse(HTTPResponse& response)
_mustReconnect = getKeepAlive() && !response.getKeepAlive();
if (!_expectResponseBody)
if (!_expectResponseBody || response.getStatus() < 200 || response.getStatus() == HTTPResponse::HTTP_NO_CONTENT || response.getStatus() == HTTPResponse::HTTP_NOT_MODIFIED)
_pResponseStream = new HTTPFixedLengthInputStream(*this, 0);
else if (response.getChunkedTransferEncoding())
_pResponseStream = new HTTPChunkedInputStream(*this);
else if (response.getContentLength() != HTTPMessage::UNKNOWN_CONTENT_LENGTH)
else if (response.hasContentLength())
#if defined(POCO_HAVE_INT64)
_pResponseStream = new HTTPFixedLengthInputStream(*this, response.getContentLength64());
#else
_pResponseStream = new HTTPFixedLengthInputStream(*this, response.getContentLength());
#endif
else
_pResponseStream = new HTTPInputStream(*this);