From e9e215dc1f37827fabd87d6fb7ed99afa843d53a Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 27 Sep 2008 16:06:34 +0000 Subject: 2008-09-27 Tatsuhiro Tsujikawa Fixed the bug that HTTPS download fails. * src/AbstractCommand.cc * src/AbstractCommand.h * src/DownloadCommand.cc * src/FtpConnection.cc * src/HttpConnection.cc * src/HttpRequestCommand.cc * src/HttpResponseCommand.cc * src/HttpSkipResponseCommand.cc * src/MSEHandshake.cc * src/PeerConnection.cc * src/SocketCore.cc * src/SocketCore.h Fixed the bug that aria2 doesn't download whole content body and cannot reuse connection if chunked transfer encoding and gzip content encoding are set. * src/DownloadCommand.cc * src/HttpSkipResponseCommand.cc --- src/HttpSkipResponseCommand.cc | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src/HttpSkipResponseCommand.cc') diff --git a/src/HttpSkipResponseCommand.cc b/src/HttpSkipResponseCommand.cc index 8ef54269..5d63a9c0 100644 --- a/src/HttpSkipResponseCommand.cc +++ b/src/HttpSkipResponseCommand.cc @@ -96,7 +96,8 @@ bool HttpSkipResponseCommand::executeInternal() // The return value is safely ignored here. _transferEncodingDecoder->decode(buf, bufSize); } - if(_totalLength != 0 && bufSize == 0) { + if(_totalLength != 0 && bufSize == 0 && + !socket->wantRead() && !socket->wantWrite()) { throw DlRetryEx(EX_GOT_EOF); } } catch(RecoverableException& e) { @@ -104,15 +105,19 @@ bool HttpSkipResponseCommand::executeInternal() return processResponse(); } - if(bufSize == 0) { - // Since this method is called by DownloadEngine only when the socket is - // readable, bufSize == 0 means server shutdown the connection. - // So socket cannot be reused in this case. - return prepareForRetry(0); - } else if((!_transferEncodingDecoder.isNull() && - _transferEncodingDecoder->finished()) - || (_transferEncodingDecoder.isNull() && - _totalLength == _receivedBytes)) { + bool finished = false; + if(_transferEncodingDecoder.isNull()) { + if(bufSize == 0) { + if(!socket->wantRead() && !socket->wantWrite()) { + return processResponse(); + } + } else { + finished = (_totalLength == _receivedBytes); + } + } else { + finished = _transferEncodingDecoder->finished(); + } + if(finished) { if(!e->option->getAsBool(PREF_HTTP_PROXY_ENABLED) && req->supportsPersistentConnection()) { std::pair peerInfo; @@ -121,6 +126,7 @@ bool HttpSkipResponseCommand::executeInternal() } return processResponse(); } else { + setWriteCheckSocketIf(socket, socket->wantWrite()); e->commands.push_back(this); return false; } -- cgit