2008-10-23 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

Pool connection when redirection occurs with Content-Length = 0.
	* src/HttpSkipResponseCommand.cc
	* src/HttpSkipResponseCommand.h
pull/1/head
Tatsuhiro Tsujikawa 2008-10-23 13:51:34 +00:00
parent d538c9ae97
commit 90c6d5072b
3 changed files with 26 additions and 6 deletions

View File

@ -1,3 +1,9 @@
2008-10-23 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Pool connection when redirection occurs with Content-Length = 0.
* src/HttpSkipResponseCommand.cc
* src/HttpSkipResponseCommand.h
2008-10-22 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com> 2008-10-22 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed the bug that causes time out when redirection occurs with Fixed the bug that causes time out when redirection occurs with

View File

@ -80,6 +80,13 @@ void HttpSkipResponseCommand::setTransferEncodingDecoder
bool HttpSkipResponseCommand::executeInternal() bool HttpSkipResponseCommand::executeInternal()
{ {
if(_totalLength == 0 && _transferEncodingDecoder.isNull()) { if(_totalLength == 0 && _transferEncodingDecoder.isNull()) {
// If content-length header is present and it's value is 0, then
// pool socket for reuse.
// If content-length header is not present, then EOF is expected in the end.
// In this case, the content is thrown away and socket cannot be pooled.
if(_httpResponse->getHttpHeader()->defined(HttpHeader::CONTENT_LENGTH)) {
poolConnection();
}
return processResponse(); return processResponse();
} }
const size_t BUFSIZE = 16*1024; const size_t BUFSIZE = 16*1024;
@ -118,12 +125,7 @@ bool HttpSkipResponseCommand::executeInternal()
finished = _transferEncodingDecoder->finished(); finished = _transferEncodingDecoder->finished();
} }
if(finished) { if(finished) {
if(!e->option->getAsBool(PREF_HTTP_PROXY_ENABLED) && poolConnection();
req->supportsPersistentConnection()) {
std::pair<std::string, uint16_t> peerInfo;
socket->getPeerInfo(peerInfo);
e->poolSocket(peerInfo.first, peerInfo.second, socket);
}
return processResponse(); return processResponse();
} else { } else {
setWriteCheckSocketIf(socket, socket->wantWrite()); setWriteCheckSocketIf(socket, socket->wantWrite());
@ -132,6 +134,16 @@ bool HttpSkipResponseCommand::executeInternal()
} }
} }
void HttpSkipResponseCommand::poolConnection() const
{
if(!e->option->getAsBool(PREF_HTTP_PROXY_ENABLED) &&
req->supportsPersistentConnection()) {
std::pair<std::string, uint16_t> peerInfo;
socket->getPeerInfo(peerInfo);
e->poolSocket(peerInfo.first, peerInfo.second, socket);
}
}
bool HttpSkipResponseCommand::processResponse() bool HttpSkipResponseCommand::processResponse()
{ {
if(_httpResponse->isRedirect()) { if(_httpResponse->isRedirect()) {

View File

@ -56,6 +56,8 @@ private:
uint64_t _receivedBytes; uint64_t _receivedBytes;
bool processResponse(); bool processResponse();
void poolConnection() const;
protected: protected:
virtual bool executeInternal(); virtual bool executeInternal();
public: public: