mirror of https://github.com/aria2/aria2
2008-05-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Set _supportsPersistentConnection to true by default. * src/Request.cc * src/RequestGroup.cc * test/HttpRequestTest.cc * test/RequestTest.ccpull/1/head
parent
2c54667beb
commit
5ea933fed1
|
@ -1,3 +1,11 @@
|
||||||
|
2008-05-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
|
Set _supportsPersistentConnection to true by default.
|
||||||
|
* src/Request.cc
|
||||||
|
* src/RequestGroup.cc
|
||||||
|
* test/HttpRequestTest.cc
|
||||||
|
* test/RequestTest.cc
|
||||||
|
|
||||||
2008-05-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
2008-05-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
Added timeout to socket pool. The default timeout is 15 seconds,
|
Added timeout to socket pool. The default timeout is 15 seconds,
|
||||||
|
|
|
@ -49,7 +49,7 @@ const std::string Request::METHOD_HEAD = "HEAD";
|
||||||
|
|
||||||
Request::Request():
|
Request::Request():
|
||||||
port(0), tryCount(0),
|
port(0), tryCount(0),
|
||||||
_supportsPersistentConnection(false),
|
_supportsPersistentConnection(true),
|
||||||
_keepAliveHint(false),
|
_keepAliveHint(false),
|
||||||
_pipeliningHint(false),
|
_pipeliningHint(false),
|
||||||
method(METHOD_GET),
|
method(METHOD_GET),
|
||||||
|
@ -70,7 +70,7 @@ bool Request::resetUrl() {
|
||||||
|
|
||||||
bool Request::redirectUrl(const std::string& url) {
|
bool Request::redirectUrl(const std::string& url) {
|
||||||
previousUrl = "";
|
previousUrl = "";
|
||||||
_supportsPersistentConnection = false;
|
_supportsPersistentConnection = true;
|
||||||
return parseUrl(url);
|
return parseUrl(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -498,14 +498,6 @@ Commands RequestGroup::createNextCommand(DownloadEngine* e, unsigned int numComm
|
||||||
req->setPipeliningHint(true);
|
req->setPipeliningHint(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(req->getProtocol() == "http" || req->getProtocol() == "https") {
|
|
||||||
// we set supportsPersistentConnection true here. When HTTP response
|
|
||||||
// is returned and it turns out that the remote server doesn't
|
|
||||||
// support persistent connection, then this value will be set to
|
|
||||||
// false.
|
|
||||||
req->supportsPersistentConnection(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
Command* command = InitiateConnectionCommandFactory::createInitiateConnectionCommand(CUIDCounterSingletonHolder::instance()->newID(), req, this, e);
|
Command* command = InitiateConnectionCommandFactory::createInitiateConnectionCommand(CUIDCounterSingletonHolder::instance()->newID(), req, this, e);
|
||||||
ServerHostHandle sv(new ServerHost(command->getCuid(), req->getHost()));
|
ServerHostHandle sv(new ServerHost(command->getCuid(), req->getHost()));
|
||||||
registerServerHost(sv);
|
registerServerHost(sv);
|
||||||
|
|
|
@ -178,7 +178,7 @@ void HttpRequestTest::testCreateRequest()
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest());
|
CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest());
|
||||||
|
|
||||||
// redirection clears persistent connection falg
|
// redirection set persistent connection flag to true
|
||||||
request->redirectUrl("http://localhost:8080/archives/download/aria2-1.0.0.tar.bz2");
|
request->redirectUrl("http://localhost:8080/archives/download/aria2-1.0.0.tar.bz2");
|
||||||
|
|
||||||
expectedText = "GET /archives/download/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
|
expectedText = "GET /archives/download/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
|
||||||
|
@ -187,8 +187,7 @@ void HttpRequestTest::testCreateRequest()
|
||||||
"Host: localhost:8080\r\n"
|
"Host: localhost:8080\r\n"
|
||||||
"Pragma: no-cache\r\n"
|
"Pragma: no-cache\r\n"
|
||||||
"Cache-Control: no-cache\r\n"
|
"Cache-Control: no-cache\r\n"
|
||||||
"Connection: close\r\n"
|
"Range: bytes=1048576-2097151\r\n"
|
||||||
"Range: bytes=1048576-\r\n"
|
|
||||||
"\r\n";
|
"\r\n";
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest());
|
CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest());
|
||||||
|
|
|
@ -271,13 +271,13 @@ void RequestTest::testSetUrl17()
|
||||||
|
|
||||||
void RequestTest::testRedirectUrl() {
|
void RequestTest::testRedirectUrl() {
|
||||||
Request req;
|
Request req;
|
||||||
req.supportsPersistentConnection(true);
|
req.supportsPersistentConnection(false);
|
||||||
req.setUrl("http://aria.rednoah.com:8080/aria2/index.html");
|
req.setUrl("http://aria.rednoah.com:8080/aria2/index.html");
|
||||||
|
|
||||||
bool v2 = req.redirectUrl("http://aria.rednoah.co.jp/");
|
bool v2 = req.redirectUrl("http://aria.rednoah.co.jp/");
|
||||||
CPPUNIT_ASSERT(v2);
|
CPPUNIT_ASSERT(v2);
|
||||||
// persistent connection flag is set to be false after redirection
|
// persistent connection flag is set to be true after redirection
|
||||||
CPPUNIT_ASSERT(!req.supportsPersistentConnection());
|
CPPUNIT_ASSERT(req.supportsPersistentConnection());
|
||||||
// url must be the same
|
// url must be the same
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com:8080/aria2/index.html"),
|
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com:8080/aria2/index.html"),
|
||||||
req.getUrl());
|
req.getUrl());
|
||||||
|
|
Loading…
Reference in New Issue