summaryrefslogtreecommitdiff
path: root/src/HttpResponseCommand.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-11-07 12:36:33 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-11-07 12:36:33 +0000
commitb4f7588ba285a8e33dc07acfa730491285cba18e (patch)
tree5f0537dee50b0036fd40c2f13fdb4175d28f8b3e /src/HttpResponseCommand.cc
parentdfd40dff54670fd3768811acf1a38be6c88b009f (diff)
2007-11-07 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Reflect the download length of in-flight pieces. It makes the download length readout more precise. * src/DefaultPieceStorage.{h, cc} * test/DefaultPieceStorageTest.cc * src/a2functional.h * test/a2functionalTest.cc Lower CPU load when --max-download-limit is used. There is up and down in speed indicator when enabling http-pipelining but a download goes well. I think the problem is that because http-pipelining is enabled, DownloadCommand is created for each segment and in its constructor, PeerStat::downloadStart() is called. In PeerStat::downloadStart(), speed calculation object is reseted, which makes download speed zero. * src/DownloadCommand.cc Rewritten using accumulate. * src/RequestGroupMan.cc (calculateStat) Code clearnup. * src/FtpNegotiationCommand.cc * src/HttpResponseCommand.cc
Diffstat (limited to 'src/HttpResponseCommand.cc')
-rw-r--r--src/HttpResponseCommand.cc23
1 files changed, 4 insertions, 19 deletions
diff --git a/src/HttpResponseCommand.cc b/src/HttpResponseCommand.cc
index dba8007f..d4a02bea 100644
--- a/src/HttpResponseCommand.cc
+++ b/src/HttpResponseCommand.cc
@@ -75,12 +75,6 @@ bool HttpResponseCommand::executeInternal()
// check HTTP status number
httpResponse->validateResponse();
httpResponse->retrieveCookie();
- // check whether the server supports persistent connections.
- /*
- if(Util::toLower(headers.getFirst("Connection")).find("close") != string::npos) {
- req->setKeepAlive(false);
- }
- */
// check whether Location header exists. If it does, update request object
// with redirected URL.
// then establish a connection to the new host and port
@@ -116,18 +110,13 @@ bool HttpResponseCommand::handleDefaultEncoding(const HttpResponseHandle& httpRe
if(size == INT64_MAX || size < 0) {
throw new DlAbortEx(EX_TOO_LARGE_FILE, Util::llitos(size, true).c_str());
}
- //_requestGroup->getSegmentMan()->isSplittable = !(size == 0);
- //_requestGroup->getSegmentMan()->totalSize = size;
- //_requestGroup->getSegmentMan()->initDownloadContext(size);
-
SingleFileDownloadContextHandle(_requestGroup->getDownloadContext())->setTotalLength(size);
initPieceStorage();
- // quick hack for method 'head'
+ // quick hack for method 'head',, is it necessary?
if(httpRequest->getMethod() == Request::METHOD_HEAD) {
// TODO because we don't want segment file to be saved.
- //_requestGroup->getSegmentMan()->isSplittable = false;
return true;
}
@@ -156,11 +145,9 @@ bool HttpResponseCommand::handleDefaultEncoding(const HttpResponseHandle& httpRe
}
bool HttpResponseCommand::handleOtherEncoding(const HttpResponseHandle& httpResponse) {
- HttpRequestHandle httpRequest = httpResponse->getHttpRequest();
// we ignore content-length when transfer-encoding is set
- //_requestGroup->getSegmentMan()->isSplittable = false;
- //_requestGroup->getSegmentMan()->totalSize = 0;
- // quick hack for method 'head'
+ HttpRequestHandle httpRequest = httpResponse->getHttpRequest();
+ // quick hack for method 'head',, is it necessary?
if(httpRequest->getMethod() == Request::METHOD_HEAD) {
return true;
}
@@ -169,11 +156,9 @@ bool HttpResponseCommand::handleOtherEncoding(const HttpResponseHandle& httpResp
initPieceStorage();
- //segment = _requestGroup->getSegmentMan()->getSegment(cuid);
-
shouldCancelDownloadForSafety();
// TODO handle file-size unknown case
- _requestGroup->getPieceStorage()->getDiskAdaptor()->initAndOpenFile();//_requestGroup->getFilePath());
+ _requestGroup->getPieceStorage()->getDiskAdaptor()->initAndOpenFile();
e->commands.push_back(createHttpDownloadCommand(httpResponse));
return true;
}