2010-03-07 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

url -> uri in Request class.
	* src/AbstractCommand.cc
	* src/AdaptiveURISelector.cc
	* src/DefaultBtAnnounce.cc
	* src/FeedbackURISelector.cc
	* src/FileEntry.cc
	* src/FileEntry.h
	* src/HttpRequest.h
	* src/HttpResponse.cc
	* src/InitiateConnectionCommandFactory.cc
	* src/Metalink2RequestGroup.cc
	* src/OptionHandlerImpl.h
	* src/ProtocolDetector.cc
	* src/Request.cc
	* src/Request.h
	* src/XmlRpcMethodImpl.cc
	* test/AuthConfigFactoryTest.cc
	* test/FtpConnectionTest.cc
	* test/HttpRequestTest.cc
	* test/HttpResponseTest.cc
	* test/RequestTest.cc
This commit is contained in:
Tatsuhiro Tsujikawa 2010-03-07 10:36:42 +00:00
parent 6ce44b001d
commit b0f180c99c
21 changed files with 372 additions and 348 deletions

View file

@ -11,72 +11,72 @@ namespace aria2 {
class RequestTest:public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(RequestTest);
CPPUNIT_TEST(testSetUrl1);
CPPUNIT_TEST(testSetUrl2);
CPPUNIT_TEST(testSetUrl3);
CPPUNIT_TEST(testSetUrl4);
CPPUNIT_TEST(testSetUrl5);
CPPUNIT_TEST(testSetUrl6);
CPPUNIT_TEST(testSetUrl7);
CPPUNIT_TEST(testSetUrl8);
CPPUNIT_TEST(testSetUrl9);
CPPUNIT_TEST(testSetUrl10);
CPPUNIT_TEST(testSetUrl11);
CPPUNIT_TEST(testSetUrl12);
CPPUNIT_TEST(testSetUrl13);
CPPUNIT_TEST(testSetUrl14);
CPPUNIT_TEST(testSetUrl15);
CPPUNIT_TEST(testSetUrl16);
CPPUNIT_TEST(testSetUrl17);
CPPUNIT_TEST(testSetUrl18);
CPPUNIT_TEST(testSetUrl19);
CPPUNIT_TEST(testSetUrl20);
CPPUNIT_TEST(testSetUrl_username);
CPPUNIT_TEST(testSetUrl_usernamePassword);
CPPUNIT_TEST(testSetUrl_zeroUsername);
CPPUNIT_TEST(testSetUrl_supportsPersistentConnection);
CPPUNIT_TEST(testSetUrl_ipv6);
CPPUNIT_TEST(testRedirectUrl);
CPPUNIT_TEST(testRedirectUrl2);
CPPUNIT_TEST(testRedirectUrl_supportsPersistentConnection);
CPPUNIT_TEST(testResetUrl);
CPPUNIT_TEST(testResetUrl_supportsPersistentConnection);
CPPUNIT_TEST(testSetUri1);
CPPUNIT_TEST(testSetUri2);
CPPUNIT_TEST(testSetUri3);
CPPUNIT_TEST(testSetUri4);
CPPUNIT_TEST(testSetUri5);
CPPUNIT_TEST(testSetUri6);
CPPUNIT_TEST(testSetUri7);
CPPUNIT_TEST(testSetUri8);
CPPUNIT_TEST(testSetUri9);
CPPUNIT_TEST(testSetUri10);
CPPUNIT_TEST(testSetUri11);
CPPUNIT_TEST(testSetUri12);
CPPUNIT_TEST(testSetUri13);
CPPUNIT_TEST(testSetUri14);
CPPUNIT_TEST(testSetUri15);
CPPUNIT_TEST(testSetUri16);
CPPUNIT_TEST(testSetUri17);
CPPUNIT_TEST(testSetUri18);
CPPUNIT_TEST(testSetUri19);
CPPUNIT_TEST(testSetUri20);
CPPUNIT_TEST(testSetUri_username);
CPPUNIT_TEST(testSetUri_usernamePassword);
CPPUNIT_TEST(testSetUri_zeroUsername);
CPPUNIT_TEST(testSetUri_supportsPersistentConnection);
CPPUNIT_TEST(testSetUri_ipv6);
CPPUNIT_TEST(testRedirectUri);
CPPUNIT_TEST(testRedirectUri2);
CPPUNIT_TEST(testRedirectUri_supportsPersistentConnection);
CPPUNIT_TEST(testResetUri);
CPPUNIT_TEST(testResetUri_supportsPersistentConnection);
CPPUNIT_TEST(testInnerLink);
CPPUNIT_TEST(testInnerLinkInReferer);
CPPUNIT_TEST(testGetURIHost);
CPPUNIT_TEST_SUITE_END();
public:
void testSetUrl1();
void testSetUrl2();
void testSetUrl3();
void testSetUrl4();
void testSetUrl5();
void testSetUrl6();
void testSetUrl7();
void testSetUrl8();
void testSetUrl9();
void testSetUrl10();
void testSetUrl11();
void testSetUrl12();
void testSetUrl13();
void testSetUrl14();
void testSetUrl15();
void testSetUrl16();
void testSetUrl17();
void testSetUrl18();
void testSetUrl19();
void testSetUrl20();
void testSetUrl_username();
void testSetUrl_usernamePassword();
void testSetUrl_zeroUsername();
void testSetUrl_supportsPersistentConnection();
void testSetUrl_ipv6();
void testRedirectUrl();
void testRedirectUrl2();
void testRedirectUrl_supportsPersistentConnection();
void testResetUrl();
void testResetUrl_supportsPersistentConnection();
void testSetUri1();
void testSetUri2();
void testSetUri3();
void testSetUri4();
void testSetUri5();
void testSetUri6();
void testSetUri7();
void testSetUri8();
void testSetUri9();
void testSetUri10();
void testSetUri11();
void testSetUri12();
void testSetUri13();
void testSetUri14();
void testSetUri15();
void testSetUri16();
void testSetUri17();
void testSetUri18();
void testSetUri19();
void testSetUri20();
void testSetUri_username();
void testSetUri_usernamePassword();
void testSetUri_zeroUsername();
void testSetUri_supportsPersistentConnection();
void testSetUri_ipv6();
void testRedirectUri();
void testRedirectUri2();
void testRedirectUri_supportsPersistentConnection();
void testResetUri();
void testResetUri_supportsPersistentConnection();
void testInnerLink();
void testInnerLinkInReferer();
void testGetURIHost();
@ -85,14 +85,14 @@ public:
CPPUNIT_TEST_SUITE_REGISTRATION( RequestTest );
void RequestTest::testSetUrl1() {
void RequestTest::testSetUri1() {
Request req;
bool v = req.setUrl("http://aria.rednoah.com/");
bool v = req.setUri("http://aria.rednoah.com/");
CPPUNIT_ASSERT(v);
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com/"), req.getUrl());
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com/"), req.getCurrentUrl());
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getPreviousUrl());
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com/"), req.getUri());
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com/"), req.getCurrentUri());
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getPreviousUri());
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
CPPUNIT_ASSERT_EQUAL((uint16_t)80, req.getPort());
CPPUNIT_ASSERT_EQUAL(std::string("aria.rednoah.com"), req.getHost());
@ -104,17 +104,17 @@ void RequestTest::testSetUrl1() {
CPPUNIT_ASSERT(!req.isIPv6LiteralAddress());
}
void RequestTest::testSetUrl2() {
void RequestTest::testSetUri2() {
Request req;
bool v = req.setUrl("http://aria.rednoah.com:8080/index.html");
bool v = req.setUri("http://aria.rednoah.com:8080/index.html");
req.setReferer("http://aria.rednoah.com:8080");
CPPUNIT_ASSERT(v);
// referer is unchaged
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com:8080"), req.getReferer());
// previousUrl must equal to referer;
CPPUNIT_ASSERT_EQUAL(req.getReferer(), req.getPreviousUrl());
// previousUri must equal to referer;
CPPUNIT_ASSERT_EQUAL(req.getReferer(), req.getPreviousUri());
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
CPPUNIT_ASSERT_EQUAL((uint16_t)8080, req.getPort());
CPPUNIT_ASSERT_EQUAL(std::string("aria.rednoah.com"), req.getHost());
@ -123,9 +123,9 @@ void RequestTest::testSetUrl2() {
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getQuery());
}
void RequestTest::testSetUrl3() {
void RequestTest::testSetUri3() {
Request req;
bool v = req.setUrl("http://aria.rednoah.com/aria2/index.html");
bool v = req.setUri("http://aria.rednoah.com/aria2/index.html");
CPPUNIT_ASSERT(v);
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
@ -136,9 +136,9 @@ void RequestTest::testSetUrl3() {
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getQuery());
}
void RequestTest::testSetUrl4() {
void RequestTest::testSetUri4() {
Request req;
bool v = req.setUrl("http://aria.rednoah.com/aria2/aria3/index.html");
bool v = req.setUri("http://aria.rednoah.com/aria2/aria3/index.html");
CPPUNIT_ASSERT(v);
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
@ -149,9 +149,9 @@ void RequestTest::testSetUrl4() {
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getQuery());
}
void RequestTest::testSetUrl5() {
void RequestTest::testSetUri5() {
Request req;
bool v = req.setUrl("http://aria.rednoah.com/aria2/aria3/");
bool v = req.setUri("http://aria.rednoah.com/aria2/aria3/");
CPPUNIT_ASSERT(v);
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
@ -162,9 +162,9 @@ void RequestTest::testSetUrl5() {
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getQuery());
}
void RequestTest::testSetUrl6() {
void RequestTest::testSetUri6() {
Request req;
bool v = req.setUrl("http://aria.rednoah.com/aria2/aria3");
bool v = req.setUri("http://aria.rednoah.com/aria2/aria3");
CPPUNIT_ASSERT(v);
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
@ -175,37 +175,37 @@ void RequestTest::testSetUrl6() {
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getQuery());
}
void RequestTest::testSetUrl7() {
void RequestTest::testSetUri7() {
Request req;
bool v = req.setUrl("http://");
bool v = req.setUri("http://");
CPPUNIT_ASSERT(!v);
}
void RequestTest::testSetUrl8() {
void RequestTest::testSetUri8() {
Request req;
bool v = req.setUrl("http:/aria.rednoah.com");
bool v = req.setUri("http:/aria.rednoah.com");
CPPUNIT_ASSERT(!v);
}
void RequestTest::testSetUrl9() {
void RequestTest::testSetUri9() {
Request req;
bool v = req.setUrl("h");
bool v = req.setUri("h");
CPPUNIT_ASSERT(!v);
}
void RequestTest::testSetUrl10() {
void RequestTest::testSetUri10() {
Request req;
bool v = req.setUrl("");
bool v = req.setUri("");
CPPUNIT_ASSERT(!v);
}
void RequestTest::testSetUrl11() {
void RequestTest::testSetUri11() {
Request req;
bool v = req.setUrl("http://host?query/");
bool v = req.setUri("http://host?query/");
CPPUNIT_ASSERT(v);
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
@ -215,9 +215,9 @@ void RequestTest::testSetUrl11() {
CPPUNIT_ASSERT_EQUAL(std::string("?query/"), req.getQuery());
}
void RequestTest::testSetUrl12() {
void RequestTest::testSetUri12() {
Request req;
bool v = req.setUrl("http://host?query");
bool v = req.setUri("http://host?query");
CPPUNIT_ASSERT(v);
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
@ -227,9 +227,9 @@ void RequestTest::testSetUrl12() {
CPPUNIT_ASSERT_EQUAL(std::string("?query"), req.getQuery());
}
void RequestTest::testSetUrl13() {
void RequestTest::testSetUri13() {
Request req;
bool v = req.setUrl("http://host/?query");
bool v = req.setUri("http://host/?query");
CPPUNIT_ASSERT(v);
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
@ -239,9 +239,9 @@ void RequestTest::testSetUrl13() {
CPPUNIT_ASSERT_EQUAL(std::string("?query"), req.getQuery());
}
void RequestTest::testSetUrl14() {
void RequestTest::testSetUri14() {
Request req;
bool v = req.setUrl("http://host:8080/abc?query");
bool v = req.setUri("http://host:8080/abc?query");
CPPUNIT_ASSERT(v);
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
@ -252,11 +252,11 @@ void RequestTest::testSetUrl14() {
CPPUNIT_ASSERT_EQUAL(std::string("?query"), req.getQuery());
}
void RequestTest::testSetUrl15()
void RequestTest::testSetUri15()
{
Request req;
// 2 slashes after host name and dir
bool v = req.setUrl("http://host//dir1/dir2//file");
bool v = req.setUri("http://host//dir1/dir2//file");
CPPUNIT_ASSERT(v);
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
CPPUNIT_ASSERT_EQUAL(std::string("host"), req.getHost());
@ -265,11 +265,11 @@ void RequestTest::testSetUrl15()
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getQuery());
}
void RequestTest::testSetUrl16()
void RequestTest::testSetUri16()
{
Request req;
// 2 slashes before file
bool v = req.setUrl("http://host//file");
bool v = req.setUri("http://host//file");
CPPUNIT_ASSERT(v);
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
CPPUNIT_ASSERT_EQUAL(std::string("host"), req.getHost());
@ -278,10 +278,10 @@ void RequestTest::testSetUrl16()
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getQuery());
}
void RequestTest::testSetUrl17()
void RequestTest::testSetUri17()
{
Request req;
bool v = req.setUrl("http://host:80/file<with%2 %20space/file with space;param%?a=/?");
bool v = req.setUri("http://host:80/file<with%2 %20space/file with space;param%?a=/?");
CPPUNIT_ASSERT(v);
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
CPPUNIT_ASSERT_EQUAL(std::string("host"), req.getHost());
@ -290,57 +290,57 @@ void RequestTest::testSetUrl17()
CPPUNIT_ASSERT_EQUAL(std::string("?a=/?"), req.getQuery());
CPPUNIT_ASSERT_EQUAL(std::string("http://host:80/file%3Cwith%252%20%20space"
"/file%20with%20space;param%25?a=/?"),
req.getCurrentUrl());
req.getCurrentUri());
CPPUNIT_ASSERT_EQUAL(std::string("http://host:80/file<with%2 %20space"
"/file with space;param%?a=/?"),
req.getUrl());
req.getUri());
}
void RequestTest::testSetUrl18() {
void RequestTest::testSetUri18() {
Request req;
bool v = req.setUrl("http://1/");
bool v = req.setUri("http://1/");
CPPUNIT_ASSERT(v);
}
void RequestTest::testSetUrl19() {
void RequestTest::testSetUri19() {
Request req;
// No host
bool v = req.setUrl("http://user@");
bool v = req.setUri("http://user@");
CPPUNIT_ASSERT(!v);
}
void RequestTest::testSetUrl20() {
void RequestTest::testSetUri20() {
Request req;
bool v;
// Invalid port
v = req.setUrl("http://localhost:65536");
v = req.setUri("http://localhost:65536");
CPPUNIT_ASSERT(!v);
v = req.setUrl("http://localhost:65535");
v = req.setUri("http://localhost:65535");
CPPUNIT_ASSERT(v);
v = req.setUrl("http://localhost:-80");
v = req.setUri("http://localhost:-80");
CPPUNIT_ASSERT(!v);
}
void RequestTest::testRedirectUrl() {
void RequestTest::testRedirectUri() {
Request req;
req.supportsPersistentConnection(false);
req.setUrl("http://aria.rednoah.com:8080/aria2/index.html");
req.setUri("http://aria.rednoah.com:8080/aria2/index.html");
bool v2 = req.redirectUrl("http://aria.rednoah.co.jp/");
bool v2 = req.redirectUri("http://aria.rednoah.co.jp/");
CPPUNIT_ASSERT(v2);
// persistent connection flag is set to be true after redirection
CPPUNIT_ASSERT(req.supportsPersistentConnection());
// url must be the same
// uri must be the same
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com:8080/aria2/"
"index.html"),
req.getUrl());
// currentUrl must be updated
req.getUri());
// currentUri must be updated
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.co.jp/"),
req.getCurrentUrl());
// previousUrl must be "" when redirection
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getPreviousUrl());
req.getCurrentUri());
// previousUri must be "" when redirection
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getPreviousUri());
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
CPPUNIT_ASSERT_EQUAL(std::string("aria.rednoah.co.jp"), req.getHost());
CPPUNIT_ASSERT_EQUAL((uint16_t)80, req.getPort());
@ -351,57 +351,57 @@ void RequestTest::testRedirectUrl() {
CPPUNIT_ASSERT_EQUAL((unsigned int)1, req.getRedirectCount());
// Give abosulute path
CPPUNIT_ASSERT(req.redirectUrl("/abspath/to/file"));
CPPUNIT_ASSERT(req.redirectUri("/abspath/to/file"));
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.co.jp/abspath/to/file"),
req.getCurrentUrl());
req.getCurrentUri());
CPPUNIT_ASSERT_EQUAL((unsigned int)2, req.getRedirectCount());
// Give relative path
CPPUNIT_ASSERT(req.redirectUrl("relativepath/to/file"));
CPPUNIT_ASSERT(req.redirectUri("relativepath/to/file"));
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.co.jp/abspath/to/"
"relativepath/to/file"),
req.getCurrentUrl());
req.getCurrentUri());
CPPUNIT_ASSERT_EQUAL((unsigned int)3, req.getRedirectCount());
// White space in path and fragment is appended.
CPPUNIT_ASSERT(req.redirectUrl("http://example.org/white space#aria2"));
CPPUNIT_ASSERT(req.redirectUri("http://example.org/white space#aria2"));
CPPUNIT_ASSERT_EQUAL(std::string("http://example.org/white%20space"),
req.getCurrentUrl());
req.getCurrentUri());
}
void RequestTest::testRedirectUrl2() {
void RequestTest::testRedirectUri2() {
Request req;
req.setUrl("http://aria.rednoah.com/download.html");
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getPreviousUrl());
req.setUri("http://aria.rednoah.com/download.html");
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getPreviousUri());
req.setReferer("http://aria.rednoah.com/");
// previousUrl is updated when referer is specified
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com/"), req.getPreviousUrl());
req.redirectUrl("http://aria.rednoah.com/403.html");
// previousUri is updated when referer is specified
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com/"), req.getPreviousUri());
req.redirectUri("http://aria.rednoah.com/403.html");
// previousUrl must be "" when redirection
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getPreviousUrl());
// previousUri must be "" when redirection
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getPreviousUri());
// referer is unchagned
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com/"), req.getReferer());
req.redirectUrl("http://aria.rednoah.com/error.html");
req.redirectUri("http://aria.rednoah.com/error.html");
// previousUrl must be "" when redirection
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getPreviousUrl());
// previousUri must be "" when redirection
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getPreviousUri());
}
void RequestTest::testResetUrl() {
void RequestTest::testResetUri() {
Request req;
req.setUrl("http://aria.rednoah.com:8080/aria2/index.html");
req.setUri("http://aria.rednoah.com:8080/aria2/index.html");
req.setReferer("http://aria.rednoah.com:8080/");
req.redirectUrl("ftp://aria.rednoah.co.jp/index_en.html?view=wide");
req.redirectUri("ftp://aria.rednoah.co.jp/index_en.html?view=wide");
bool v3 = req.resetUrl();
bool v3 = req.resetUri();
CPPUNIT_ASSERT(v3);
// currentUrl must equal to url
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com:8080/aria2/index.html"), req.getUrl());
CPPUNIT_ASSERT_EQUAL(req.getUrl(), req.getCurrentUrl());
// previousUrl must equal to referer
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com:8080/"), req.getPreviousUrl());
// currentUri must equal to uri
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com:8080/aria2/index.html"), req.getUri());
CPPUNIT_ASSERT_EQUAL(req.getUri(), req.getCurrentUri());
// previousUri must equal to referer
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com:8080/"), req.getPreviousUri());
// referer is unchanged
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com:8080/"), req.getReferer());
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
@ -414,13 +414,13 @@ void RequestTest::testResetUrl() {
void RequestTest::testInnerLink() {
Request req;
bool v = req.setUrl("http://aria.rednoah.com/index.html#download");
bool v = req.setUri("http://aria.rednoah.com/index.html#download");
CPPUNIT_ASSERT(v);
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com/index.html"
"#download"),
req.getUrl());
req.getUri());
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com/index.html"),
req.getCurrentUrl());
req.getCurrentUri());
CPPUNIT_ASSERT_EQUAL(std::string("index.html"), req.getFile());
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getQuery());
}
@ -432,10 +432,10 @@ void RequestTest::testInnerLinkInReferer() {
req.getReferer());
}
void RequestTest::testSetUrl_zeroUsername()
void RequestTest::testSetUri_zeroUsername()
{
Request req;
CPPUNIT_ASSERT(req.setUrl("ftp://@localhost/download/aria2-1.0.0.tar.bz2"));
CPPUNIT_ASSERT(req.setUri("ftp://@localhost/download/aria2-1.0.0.tar.bz2"));
CPPUNIT_ASSERT_EQUAL(std::string("ftp"), req.getProtocol());
CPPUNIT_ASSERT_EQUAL((uint16_t)21, req.getPort());
CPPUNIT_ASSERT_EQUAL(std::string("localhost"), req.getHost());
@ -444,7 +444,7 @@ void RequestTest::testSetUrl_zeroUsername()
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getUsername());
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getPassword());
CPPUNIT_ASSERT(req.setUrl("ftp://:@localhost/download/aria2-1.0.0.tar.bz2"));
CPPUNIT_ASSERT(req.setUri("ftp://:@localhost/download/aria2-1.0.0.tar.bz2"));
CPPUNIT_ASSERT_EQUAL(std::string("ftp"), req.getProtocol());
CPPUNIT_ASSERT_EQUAL((uint16_t)21, req.getPort());
CPPUNIT_ASSERT_EQUAL(std::string("localhost"), req.getHost());
@ -453,7 +453,7 @@ void RequestTest::testSetUrl_zeroUsername()
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getUsername());
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getPassword());
CPPUNIT_ASSERT(req.setUrl("ftp://:pass@localhost/download/aria2-1.0.0.tar.bz2"));
CPPUNIT_ASSERT(req.setUri("ftp://:pass@localhost/download/aria2-1.0.0.tar.bz2"));
CPPUNIT_ASSERT_EQUAL(std::string("ftp"), req.getProtocol());
CPPUNIT_ASSERT_EQUAL((uint16_t)21, req.getPort());
CPPUNIT_ASSERT_EQUAL(std::string("localhost"), req.getHost());
@ -464,10 +464,10 @@ void RequestTest::testSetUrl_zeroUsername()
}
void RequestTest::testSetUrl_username()
void RequestTest::testSetUri_username()
{
Request req;
CPPUNIT_ASSERT(req.setUrl("ftp://aria2user@localhost/download/aria2-1.0.0.tar.bz2"));
CPPUNIT_ASSERT(req.setUri("ftp://aria2user@localhost/download/aria2-1.0.0.tar.bz2"));
CPPUNIT_ASSERT_EQUAL(std::string("ftp"), req.getProtocol());
CPPUNIT_ASSERT_EQUAL((uint16_t)21, req.getPort());
CPPUNIT_ASSERT_EQUAL(std::string("localhost"), req.getHost());
@ -477,10 +477,10 @@ void RequestTest::testSetUrl_username()
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getPassword());
}
void RequestTest::testSetUrl_usernamePassword()
void RequestTest::testSetUri_usernamePassword()
{
Request req;
CPPUNIT_ASSERT(req.setUrl("ftp://aria2user%40:aria2pass%40@localhost/download/aria2-1.0.0.tar.bz2"));
CPPUNIT_ASSERT(req.setUri("ftp://aria2user%40:aria2pass%40@localhost/download/aria2-1.0.0.tar.bz2"));
CPPUNIT_ASSERT_EQUAL(std::string("ftp"), req.getProtocol());
CPPUNIT_ASSERT_EQUAL((uint16_t)21, req.getPort());
CPPUNIT_ASSERT_EQUAL(std::string("localhost"), req.getHost());
@ -489,51 +489,51 @@ void RequestTest::testSetUrl_usernamePassword()
CPPUNIT_ASSERT_EQUAL(std::string("aria2user@"), req.getUsername());
CPPUNIT_ASSERT_EQUAL(std::string("aria2pass@"), req.getPassword());
// make sure that after new url is set, username and password are updated.
CPPUNIT_ASSERT(req.setUrl("ftp://localhost/download/aria2-1.0.0.tar.bz2"));
// make sure that after new uri is set, username and password are updated.
CPPUNIT_ASSERT(req.setUri("ftp://localhost/download/aria2-1.0.0.tar.bz2"));
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getUsername());
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getPassword());
}
void RequestTest::testSetUrl_supportsPersistentConnection()
void RequestTest::testSetUri_supportsPersistentConnection()
{
Request req;
CPPUNIT_ASSERT(req.setUrl("http://host/file"));
CPPUNIT_ASSERT(req.setUri("http://host/file"));
req.supportsPersistentConnection(false);
CPPUNIT_ASSERT(!req.supportsPersistentConnection());
req.setUrl("http://host/file");
req.setUri("http://host/file");
CPPUNIT_ASSERT(req.supportsPersistentConnection());
}
void RequestTest::testResetUrl_supportsPersistentConnection()
void RequestTest::testResetUri_supportsPersistentConnection()
{
Request req;
CPPUNIT_ASSERT(req.setUrl("http://host/file"));
CPPUNIT_ASSERT(req.setUri("http://host/file"));
req.supportsPersistentConnection(false);
CPPUNIT_ASSERT(!req.supportsPersistentConnection());
req.resetUrl();
req.resetUri();
CPPUNIT_ASSERT(req.supportsPersistentConnection());
}
void RequestTest::testRedirectUrl_supportsPersistentConnection()
void RequestTest::testRedirectUri_supportsPersistentConnection()
{
Request req;
CPPUNIT_ASSERT(req.setUrl("http://host/file"));
CPPUNIT_ASSERT(req.setUri("http://host/file"));
req.supportsPersistentConnection(false);
CPPUNIT_ASSERT(!req.supportsPersistentConnection());
req.redirectUrl("http://host/file");
req.redirectUri("http://host/file");
CPPUNIT_ASSERT(req.supportsPersistentConnection());
}
void RequestTest::testSetUrl_ipv6()
void RequestTest::testSetUri_ipv6()
{
Request req;
CPPUNIT_ASSERT(!req.setUrl("http://[::1"));
CPPUNIT_ASSERT(req.setUrl("http://[::1]"));
CPPUNIT_ASSERT(!req.setUri("http://[::1"));
CPPUNIT_ASSERT(req.setUri("http://[::1]"));
CPPUNIT_ASSERT_EQUAL(std::string("::1"), req.getHost());
CPPUNIT_ASSERT(req.setUrl("http://[::1]:8000/dir/file"));
CPPUNIT_ASSERT(req.setUri("http://[::1]:8000/dir/file"));
CPPUNIT_ASSERT_EQUAL(std::string("::1"), req.getHost());
CPPUNIT_ASSERT_EQUAL((uint16_t)8000, req.getPort());
CPPUNIT_ASSERT_EQUAL(std::string("/dir"), req.getDir());
@ -544,7 +544,7 @@ void RequestTest::testSetUrl_ipv6()
void RequestTest::testGetURIHost()
{
Request req;
CPPUNIT_ASSERT(req.setUrl("http://[::1]"));
CPPUNIT_ASSERT(req.setUri("http://[::1]"));
CPPUNIT_ASSERT_EQUAL(std::string("[::1]"), req.getURIHost());
}