2006-02-17 13:35:04 +00:00
|
|
|
#include "Request.h"
|
2008-10-08 15:35:52 +00:00
|
|
|
|
|
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
|
2007-03-18 15:42:34 +00:00
|
|
|
#include "Netrc.h"
|
2007-03-21 10:19:23 +00:00
|
|
|
#include "DefaultAuthResolver.h"
|
|
|
|
#include "NetrcAuthResolver.h"
|
2006-02-17 13:35:04 +00:00
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
namespace aria2 {
|
|
|
|
|
2006-02-17 13:35:04 +00:00
|
|
|
class RequestTest:public CppUnit::TestFixture {
|
|
|
|
|
|
|
|
CPPUNIT_TEST_SUITE(RequestTest);
|
2010-03-07 10:36:42 +00:00
|
|
|
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);
|
2006-07-20 15:48:12 +00:00
|
|
|
CPPUNIT_TEST(testInnerLink);
|
2008-10-08 15:35:52 +00:00
|
|
|
CPPUNIT_TEST(testInnerLinkInReferer);
|
2009-08-30 15:05:30 +00:00
|
|
|
CPPUNIT_TEST(testGetURIHost);
|
2006-02-17 13:35:04 +00:00
|
|
|
CPPUNIT_TEST_SUITE_END();
|
|
|
|
|
|
|
|
public:
|
2010-03-07 10:36:42 +00:00
|
|
|
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();
|
2006-07-20 15:48:12 +00:00
|
|
|
void testInnerLink();
|
2008-10-08 15:35:52 +00:00
|
|
|
void testInnerLinkInReferer();
|
2009-08-30 15:05:30 +00:00
|
|
|
void testGetURIHost();
|
2006-02-17 13:35:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION( RequestTest );
|
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
void RequestTest::testSetUri1() {
|
2006-02-17 13:35:04 +00:00
|
|
|
Request req;
|
2010-03-07 10:36:42 +00:00
|
|
|
bool v = req.setUri("http://aria.rednoah.com/");
|
2006-02-17 13:35:04 +00:00
|
|
|
|
|
|
|
CPPUNIT_ASSERT(v);
|
2010-03-07 10:36:42 +00:00
|
|
|
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());
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
|
2008-03-09 12:24:01 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((uint16_t)80, req.getPort());
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("aria.rednoah.com"), req.getHost());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("/"), req.getDir());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getFile());
|
2008-04-27 04:09:08 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getQuery());
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getUsername());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getPassword());
|
2009-08-30 15:05:30 +00:00
|
|
|
CPPUNIT_ASSERT(!req.isIPv6LiteralAddress());
|
2006-02-17 13:35:04 +00:00
|
|
|
}
|
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
void RequestTest::testSetUri2() {
|
2006-02-17 13:35:04 +00:00
|
|
|
Request req;
|
2010-03-07 10:36:42 +00:00
|
|
|
bool v = req.setUri("http://aria.rednoah.com:8080/index.html");
|
2006-02-18 03:59:26 +00:00
|
|
|
req.setReferer("http://aria.rednoah.com:8080");
|
2006-02-17 13:35:04 +00:00
|
|
|
|
|
|
|
CPPUNIT_ASSERT(v);
|
2006-02-18 03:59:26 +00:00
|
|
|
|
|
|
|
// referer is unchaged
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com:8080"), req.getReferer());
|
2010-03-07 10:36:42 +00:00
|
|
|
// previousUri must equal to referer;
|
|
|
|
CPPUNIT_ASSERT_EQUAL(req.getReferer(), req.getPreviousUri());
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
|
2008-03-09 12:24:01 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((uint16_t)8080, req.getPort());
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("aria.rednoah.com"), req.getHost());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("/"), req.getDir());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("index.html"), req.getFile());
|
2008-04-27 04:09:08 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getQuery());
|
2006-02-17 13:35:04 +00:00
|
|
|
}
|
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
void RequestTest::testSetUri3() {
|
2006-02-17 13:35:04 +00:00
|
|
|
Request req;
|
2010-03-07 10:36:42 +00:00
|
|
|
bool v = req.setUri("http://aria.rednoah.com/aria2/index.html");
|
2006-02-17 13:35:04 +00:00
|
|
|
|
|
|
|
CPPUNIT_ASSERT(v);
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
|
2008-03-09 12:24:01 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((uint16_t)80, req.getPort());
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("aria.rednoah.com"), req.getHost());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("/aria2"), req.getDir());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("index.html"), req.getFile());
|
2008-04-27 04:09:08 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getQuery());
|
2006-02-17 13:35:04 +00:00
|
|
|
}
|
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
void RequestTest::testSetUri4() {
|
2006-02-17 13:35:04 +00:00
|
|
|
Request req;
|
2010-03-07 10:36:42 +00:00
|
|
|
bool v = req.setUri("http://aria.rednoah.com/aria2/aria3/index.html");
|
2006-02-17 13:35:04 +00:00
|
|
|
|
|
|
|
CPPUNIT_ASSERT(v);
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
|
2008-03-09 12:24:01 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((uint16_t)80, req.getPort());
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("aria.rednoah.com"), req.getHost());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("/aria2/aria3"), req.getDir());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("index.html"), req.getFile());
|
2008-04-27 04:09:08 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getQuery());
|
2006-02-17 13:35:04 +00:00
|
|
|
}
|
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
void RequestTest::testSetUri5() {
|
2006-02-17 13:35:04 +00:00
|
|
|
Request req;
|
2010-03-07 10:36:42 +00:00
|
|
|
bool v = req.setUri("http://aria.rednoah.com/aria2/aria3/");
|
2006-02-17 13:35:04 +00:00
|
|
|
|
|
|
|
CPPUNIT_ASSERT(v);
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
|
2008-03-09 12:24:01 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((uint16_t)80, req.getPort());
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("aria.rednoah.com"), req.getHost());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("/aria2/aria3"), req.getDir());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getFile());
|
2008-04-27 04:09:08 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getQuery());
|
2006-02-17 13:35:04 +00:00
|
|
|
}
|
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
void RequestTest::testSetUri6() {
|
2006-02-17 13:35:04 +00:00
|
|
|
Request req;
|
2010-03-07 10:36:42 +00:00
|
|
|
bool v = req.setUri("http://aria.rednoah.com/aria2/aria3");
|
2006-02-17 13:35:04 +00:00
|
|
|
|
|
|
|
CPPUNIT_ASSERT(v);
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
|
2008-03-09 12:24:01 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((uint16_t)80, req.getPort());
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("aria.rednoah.com"), req.getHost());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("/aria2"), req.getDir());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("aria3"), req.getFile());
|
2008-04-27 04:09:08 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getQuery());
|
2006-02-17 13:35:04 +00:00
|
|
|
}
|
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
void RequestTest::testSetUri7() {
|
2006-02-17 13:35:04 +00:00
|
|
|
Request req;
|
2010-03-07 10:36:42 +00:00
|
|
|
bool v = req.setUri("http://");
|
2006-02-17 13:35:04 +00:00
|
|
|
|
|
|
|
CPPUNIT_ASSERT(!v);
|
|
|
|
}
|
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
void RequestTest::testSetUri8() {
|
2006-02-17 13:35:04 +00:00
|
|
|
Request req;
|
2010-03-07 10:36:42 +00:00
|
|
|
bool v = req.setUri("http:/aria.rednoah.com");
|
2006-02-17 13:35:04 +00:00
|
|
|
|
|
|
|
CPPUNIT_ASSERT(!v);
|
|
|
|
}
|
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
void RequestTest::testSetUri9() {
|
2006-02-17 13:35:04 +00:00
|
|
|
Request req;
|
2010-03-07 10:36:42 +00:00
|
|
|
bool v = req.setUri("h");
|
2006-02-17 13:35:04 +00:00
|
|
|
|
|
|
|
CPPUNIT_ASSERT(!v);
|
|
|
|
}
|
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
void RequestTest::testSetUri10() {
|
2006-02-17 13:35:04 +00:00
|
|
|
Request req;
|
2010-03-07 10:36:42 +00:00
|
|
|
bool v = req.setUri("");
|
2006-02-17 13:35:04 +00:00
|
|
|
|
|
|
|
CPPUNIT_ASSERT(!v);
|
|
|
|
}
|
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
void RequestTest::testSetUri11() {
|
2006-06-18 09:23:25 +00:00
|
|
|
Request req;
|
2010-03-07 10:36:42 +00:00
|
|
|
bool v = req.setUri("http://host?query/");
|
2007-11-11 04:25:56 +00:00
|
|
|
|
2006-06-18 09:23:25 +00:00
|
|
|
CPPUNIT_ASSERT(v);
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("host"), req.getHost());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("/"), req.getDir());
|
2008-04-27 04:09:08 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getFile());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("?query/"), req.getQuery());
|
2006-06-18 09:23:25 +00:00
|
|
|
}
|
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
void RequestTest::testSetUri12() {
|
2006-06-18 09:23:25 +00:00
|
|
|
Request req;
|
2010-03-07 10:36:42 +00:00
|
|
|
bool v = req.setUri("http://host?query");
|
2006-06-18 09:23:25 +00:00
|
|
|
|
|
|
|
CPPUNIT_ASSERT(v);
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("host"), req.getHost());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("/"), req.getDir());
|
2008-04-27 04:09:08 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getFile());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("?query"), req.getQuery());
|
2006-06-18 09:23:25 +00:00
|
|
|
}
|
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
void RequestTest::testSetUri13() {
|
2006-06-18 09:23:25 +00:00
|
|
|
Request req;
|
2010-03-07 10:36:42 +00:00
|
|
|
bool v = req.setUri("http://host/?query");
|
2006-06-18 09:23:25 +00:00
|
|
|
|
|
|
|
CPPUNIT_ASSERT(v);
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("host"), req.getHost());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("/"), req.getDir());
|
2008-04-27 04:09:08 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getFile());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("?query"), req.getQuery());
|
2006-06-18 09:23:25 +00:00
|
|
|
}
|
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
void RequestTest::testSetUri14() {
|
2006-06-18 09:23:25 +00:00
|
|
|
Request req;
|
2010-03-07 10:36:42 +00:00
|
|
|
bool v = req.setUri("http://host:8080/abc?query");
|
2006-06-18 09:23:25 +00:00
|
|
|
|
|
|
|
CPPUNIT_ASSERT(v);
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("host"), req.getHost());
|
2008-03-09 12:24:01 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((uint16_t)8080, req.getPort());
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("/"), req.getDir());
|
2008-04-27 04:09:08 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("abc"), req.getFile());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("?query"), req.getQuery());
|
2006-06-18 09:23:25 +00:00
|
|
|
}
|
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
void RequestTest::testSetUri15()
|
2007-10-14 16:29:05 +00:00
|
|
|
{
|
|
|
|
Request req;
|
|
|
|
// 2 slashes after host name and dir
|
2010-03-07 10:36:42 +00:00
|
|
|
bool v = req.setUri("http://host//dir1/dir2//file");
|
2007-10-14 16:29:05 +00:00
|
|
|
CPPUNIT_ASSERT(v);
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("host"), req.getHost());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("/dir1/dir2"), req.getDir());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("file"), req.getFile());
|
2008-04-27 04:09:08 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getQuery());
|
2007-10-14 16:29:05 +00:00
|
|
|
}
|
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
void RequestTest::testSetUri16()
|
2007-10-14 16:29:05 +00:00
|
|
|
{
|
|
|
|
Request req;
|
|
|
|
// 2 slashes before file
|
2010-03-07 10:36:42 +00:00
|
|
|
bool v = req.setUri("http://host//file");
|
2007-10-14 16:29:05 +00:00
|
|
|
CPPUNIT_ASSERT(v);
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("host"), req.getHost());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("/"), req.getDir());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("file"), req.getFile());
|
2008-04-27 04:09:08 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getQuery());
|
2007-10-14 16:29:05 +00:00
|
|
|
}
|
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
void RequestTest::testSetUri17()
|
2007-11-11 04:25:56 +00:00
|
|
|
{
|
|
|
|
Request req;
|
2010-03-07 10:36:42 +00:00
|
|
|
bool v = req.setUri("http://host:80/file<with%2 %20space/file with space;param%?a=/?");
|
2007-11-11 04:25:56 +00:00
|
|
|
CPPUNIT_ASSERT(v);
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("host"), req.getHost());
|
2008-11-27 15:29:15 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("/file%3Cwith%252%20%20space"), req.getDir());
|
2008-10-08 16:06:27 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("file%20with%20space;param%25"), req.getFile());
|
2008-04-27 04:09:08 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("?a=/?"), req.getQuery());
|
2008-11-27 15:29:15 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http://host:80/file%3Cwith%252%20%20space"
|
2010-01-05 16:01:46 +00:00
|
|
|
"/file%20with%20space;param%25?a=/?"),
|
2010-03-07 10:36:42 +00:00
|
|
|
req.getCurrentUri());
|
2008-11-18 15:10:47 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http://host:80/file<with%2 %20space"
|
2010-01-05 16:01:46 +00:00
|
|
|
"/file with space;param%?a=/?"),
|
2010-03-07 10:36:42 +00:00
|
|
|
req.getUri());
|
2007-11-11 04:25:56 +00:00
|
|
|
}
|
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
void RequestTest::testSetUri18() {
|
2009-11-12 14:50:23 +00:00
|
|
|
Request req;
|
2010-03-07 10:36:42 +00:00
|
|
|
bool v = req.setUri("http://1/");
|
2009-11-12 14:50:23 +00:00
|
|
|
|
|
|
|
CPPUNIT_ASSERT(v);
|
|
|
|
}
|
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
void RequestTest::testSetUri19() {
|
2009-11-12 14:50:23 +00:00
|
|
|
Request req;
|
|
|
|
// No host
|
2010-03-07 10:36:42 +00:00
|
|
|
bool v = req.setUri("http://user@");
|
2009-11-12 14:50:23 +00:00
|
|
|
|
|
|
|
CPPUNIT_ASSERT(!v);
|
2009-11-15 13:00:23 +00:00
|
|
|
}
|
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
void RequestTest::testSetUri20() {
|
2009-11-15 13:00:23 +00:00
|
|
|
Request req;
|
|
|
|
bool v;
|
|
|
|
// Invalid port
|
2010-03-07 10:36:42 +00:00
|
|
|
v = req.setUri("http://localhost:65536");
|
2009-11-15 13:00:23 +00:00
|
|
|
CPPUNIT_ASSERT(!v);
|
2010-03-07 10:36:42 +00:00
|
|
|
v = req.setUri("http://localhost:65535");
|
2009-11-15 13:00:23 +00:00
|
|
|
CPPUNIT_ASSERT(v);
|
2010-03-07 10:36:42 +00:00
|
|
|
v = req.setUri("http://localhost:-80");
|
2009-11-15 13:00:23 +00:00
|
|
|
CPPUNIT_ASSERT(!v);
|
2009-11-12 14:50:23 +00:00
|
|
|
}
|
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
void RequestTest::testRedirectUri() {
|
2006-02-17 13:35:04 +00:00
|
|
|
Request req;
|
2008-05-08 13:20:15 +00:00
|
|
|
req.supportsPersistentConnection(false);
|
2010-03-07 10:36:42 +00:00
|
|
|
req.setUri("http://aria.rednoah.com:8080/aria2/index.html");
|
2006-02-17 13:35:04 +00:00
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
bool v2 = req.redirectUri("http://aria.rednoah.co.jp/");
|
2006-02-17 13:35:04 +00:00
|
|
|
CPPUNIT_ASSERT(v2);
|
2008-05-08 13:20:15 +00:00
|
|
|
// persistent connection flag is set to be true after redirection
|
|
|
|
CPPUNIT_ASSERT(req.supportsPersistentConnection());
|
2010-03-07 10:36:42 +00:00
|
|
|
// uri must be the same
|
2008-07-18 15:20:52 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com:8080/aria2/"
|
2010-01-05 16:01:46 +00:00
|
|
|
"index.html"),
|
2010-03-07 10:36:42 +00:00
|
|
|
req.getUri());
|
|
|
|
// currentUri must be updated
|
2008-07-18 15:20:52 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.co.jp/"),
|
2010-03-07 10:36:42 +00:00
|
|
|
req.getCurrentUri());
|
|
|
|
// previousUri must be "" when redirection
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getPreviousUri());
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("aria.rednoah.co.jp"), req.getHost());
|
2008-03-09 12:24:01 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((uint16_t)80, req.getPort());
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("/"), req.getDir());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getFile());
|
2008-04-27 04:09:08 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getQuery());
|
2008-06-17 09:09:31 +00:00
|
|
|
// See redirect count is incremented.
|
|
|
|
CPPUNIT_ASSERT_EQUAL((unsigned int)1, req.getRedirectCount());
|
2008-07-18 15:20:52 +00:00
|
|
|
|
|
|
|
// Give abosulute path
|
2010-03-07 10:36:42 +00:00
|
|
|
CPPUNIT_ASSERT(req.redirectUri("/abspath/to/file"));
|
2008-07-18 15:20:52 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.co.jp/abspath/to/file"),
|
2010-03-07 10:36:42 +00:00
|
|
|
req.getCurrentUri());
|
2008-07-18 15:20:52 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((unsigned int)2, req.getRedirectCount());
|
|
|
|
|
|
|
|
// Give relative path
|
2010-03-07 10:36:42 +00:00
|
|
|
CPPUNIT_ASSERT(req.redirectUri("relativepath/to/file"));
|
2008-07-18 15:20:52 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.co.jp/abspath/to/"
|
2010-01-05 16:01:46 +00:00
|
|
|
"relativepath/to/file"),
|
2010-03-07 10:36:42 +00:00
|
|
|
req.getCurrentUri());
|
2008-07-18 15:20:52 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((unsigned int)3, req.getRedirectCount());
|
2010-01-26 12:39:22 +00:00
|
|
|
|
2010-02-03 13:49:22 +00:00
|
|
|
// White space in path and fragment is appended.
|
2010-03-07 10:36:42 +00:00
|
|
|
CPPUNIT_ASSERT(req.redirectUri("http://example.org/white space#aria2"));
|
2010-01-26 12:39:22 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http://example.org/white%20space"),
|
2010-03-07 10:36:42 +00:00
|
|
|
req.getCurrentUri());
|
2006-02-17 13:35:04 +00:00
|
|
|
}
|
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
void RequestTest::testRedirectUri2() {
|
2006-02-18 03:59:26 +00:00
|
|
|
Request req;
|
2010-03-07 10:36:42 +00:00
|
|
|
req.setUri("http://aria.rednoah.com/download.html");
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getPreviousUri());
|
2006-02-18 03:59:26 +00:00
|
|
|
req.setReferer("http://aria.rednoah.com/");
|
2010-03-07 10:36:42 +00:00
|
|
|
// 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");
|
2006-02-18 03:59:26 +00:00
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
// previousUri must be "" when redirection
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getPreviousUri());
|
2006-02-18 03:59:26 +00:00
|
|
|
// referer is unchagned
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com/"), req.getReferer());
|
2006-02-18 03:59:26 +00:00
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
req.redirectUri("http://aria.rednoah.com/error.html");
|
2006-02-18 03:59:26 +00:00
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
// previousUri must be "" when redirection
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getPreviousUri());
|
2006-02-18 03:59:26 +00:00
|
|
|
}
|
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
void RequestTest::testResetUri() {
|
2006-02-17 13:35:04 +00:00
|
|
|
Request req;
|
2010-03-07 10:36:42 +00:00
|
|
|
req.setUri("http://aria.rednoah.com:8080/aria2/index.html");
|
2006-02-18 03:59:26 +00:00
|
|
|
req.setReferer("http://aria.rednoah.com:8080/");
|
2010-03-07 10:36:42 +00:00
|
|
|
req.redirectUri("ftp://aria.rednoah.co.jp/index_en.html?view=wide");
|
2006-02-17 13:35:04 +00:00
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
bool v3 = req.resetUri();
|
2006-02-17 13:35:04 +00:00
|
|
|
CPPUNIT_ASSERT(v3);
|
2010-03-07 10:36:42 +00:00
|
|
|
// 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());
|
2006-02-18 03:59:26 +00:00
|
|
|
// referer is unchanged
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com:8080/"), req.getReferer());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
|
2008-03-09 12:24:01 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((uint16_t)8080, req.getPort());
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("aria.rednoah.com"), req.getHost());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("/aria2"), req.getDir());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("index.html"), req.getFile());
|
2008-04-27 04:09:08 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getQuery());
|
2006-02-17 13:35:04 +00:00
|
|
|
}
|
|
|
|
|
2006-07-20 15:48:12 +00:00
|
|
|
void RequestTest::testInnerLink() {
|
|
|
|
Request req;
|
2010-03-07 10:36:42 +00:00
|
|
|
bool v = req.setUri("http://aria.rednoah.com/index.html#download");
|
2006-07-20 15:48:12 +00:00
|
|
|
CPPUNIT_ASSERT(v);
|
2008-11-18 15:10:47 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com/index.html"
|
2010-01-05 16:01:46 +00:00
|
|
|
"#download"),
|
2010-03-07 10:36:42 +00:00
|
|
|
req.getUri());
|
2008-10-08 15:35:52 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com/index.html"),
|
2010-03-07 10:36:42 +00:00
|
|
|
req.getCurrentUri());
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("index.html"), req.getFile());
|
2008-04-27 04:09:08 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getQuery());
|
2006-07-20 15:48:12 +00:00
|
|
|
}
|
|
|
|
|
2008-10-08 15:35:52 +00:00
|
|
|
void RequestTest::testInnerLinkInReferer() {
|
|
|
|
Request req;
|
|
|
|
req.setReferer("http://aria.rednoah.com/home.html#top");
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com/home.html"),
|
2010-01-05 16:01:46 +00:00
|
|
|
req.getReferer());
|
2008-10-08 15:35:52 +00:00
|
|
|
}
|
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
void RequestTest::testSetUri_zeroUsername()
|
2007-03-18 15:42:34 +00:00
|
|
|
{
|
|
|
|
Request req;
|
2010-03-07 10:36:42 +00:00
|
|
|
CPPUNIT_ASSERT(req.setUri("ftp://@localhost/download/aria2-1.0.0.tar.bz2"));
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("ftp"), req.getProtocol());
|
2008-03-09 12:24:01 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((uint16_t)21, req.getPort());
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("localhost"), req.getHost());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("/download"), req.getDir());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("aria2-1.0.0.tar.bz2"), req.getFile());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getUsername());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getPassword());
|
2007-10-30 12:48:01 +00:00
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
CPPUNIT_ASSERT(req.setUri("ftp://:@localhost/download/aria2-1.0.0.tar.bz2"));
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("ftp"), req.getProtocol());
|
2008-03-09 12:24:01 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((uint16_t)21, req.getPort());
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("localhost"), req.getHost());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("/download"), req.getDir());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("aria2-1.0.0.tar.bz2"), req.getFile());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getUsername());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getPassword());
|
2007-10-30 12:48:01 +00:00
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
CPPUNIT_ASSERT(req.setUri("ftp://:pass@localhost/download/aria2-1.0.0.tar.bz2"));
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("ftp"), req.getProtocol());
|
2008-03-09 12:24:01 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((uint16_t)21, req.getPort());
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("localhost"), req.getHost());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("/download"), req.getDir());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("aria2-1.0.0.tar.bz2"), req.getFile());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getUsername());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("pass"), req.getPassword());
|
2007-03-18 15:42:34 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
void RequestTest::testSetUri_username()
|
2007-03-18 15:42:34 +00:00
|
|
|
{
|
|
|
|
Request req;
|
2010-03-07 10:36:42 +00:00
|
|
|
CPPUNIT_ASSERT(req.setUri("ftp://aria2user@localhost/download/aria2-1.0.0.tar.bz2"));
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("ftp"), req.getProtocol());
|
2008-03-09 12:24:01 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((uint16_t)21, req.getPort());
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("localhost"), req.getHost());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("/download"), req.getDir());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("aria2-1.0.0.tar.bz2"), req.getFile());
|
2008-09-25 16:06:29 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("aria2user"), req.getUsername());
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getPassword());
|
2007-03-18 15:42:34 +00:00
|
|
|
}
|
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
void RequestTest::testSetUri_usernamePassword()
|
2007-03-18 15:42:34 +00:00
|
|
|
{
|
|
|
|
Request req;
|
2010-03-07 10:36:42 +00:00
|
|
|
CPPUNIT_ASSERT(req.setUri("ftp://aria2user%40:aria2pass%40@localhost/download/aria2-1.0.0.tar.bz2"));
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("ftp"), req.getProtocol());
|
2008-03-09 12:24:01 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((uint16_t)21, req.getPort());
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("localhost"), req.getHost());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("/download"), req.getDir());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("aria2-1.0.0.tar.bz2"), req.getFile());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("aria2user@"), req.getUsername());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("aria2pass@"), req.getPassword());
|
2007-10-30 12:48:01 +00:00
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
// 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"));
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getUsername());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getPassword());
|
2007-10-30 12:48:01 +00:00
|
|
|
|
2007-03-18 15:42:34 +00:00
|
|
|
}
|
2008-02-08 15:53:45 +00:00
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
void RequestTest::testSetUri_supportsPersistentConnection()
|
2008-12-15 15:38:07 +00:00
|
|
|
{
|
|
|
|
Request req;
|
2010-03-07 10:36:42 +00:00
|
|
|
CPPUNIT_ASSERT(req.setUri("http://host/file"));
|
2008-12-15 15:38:07 +00:00
|
|
|
req.supportsPersistentConnection(false);
|
|
|
|
CPPUNIT_ASSERT(!req.supportsPersistentConnection());
|
2010-03-07 10:36:42 +00:00
|
|
|
req.setUri("http://host/file");
|
2008-12-15 15:38:07 +00:00
|
|
|
CPPUNIT_ASSERT(req.supportsPersistentConnection());
|
|
|
|
}
|
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
void RequestTest::testResetUri_supportsPersistentConnection()
|
2008-12-15 15:38:07 +00:00
|
|
|
{
|
|
|
|
Request req;
|
2010-03-07 10:36:42 +00:00
|
|
|
CPPUNIT_ASSERT(req.setUri("http://host/file"));
|
2008-12-15 15:38:07 +00:00
|
|
|
req.supportsPersistentConnection(false);
|
|
|
|
CPPUNIT_ASSERT(!req.supportsPersistentConnection());
|
2010-03-07 10:36:42 +00:00
|
|
|
req.resetUri();
|
2008-12-15 15:38:07 +00:00
|
|
|
CPPUNIT_ASSERT(req.supportsPersistentConnection());
|
|
|
|
}
|
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
void RequestTest::testRedirectUri_supportsPersistentConnection()
|
2008-12-15 15:38:07 +00:00
|
|
|
{
|
|
|
|
Request req;
|
2010-03-07 10:36:42 +00:00
|
|
|
CPPUNIT_ASSERT(req.setUri("http://host/file"));
|
2008-12-15 15:38:07 +00:00
|
|
|
req.supportsPersistentConnection(false);
|
|
|
|
CPPUNIT_ASSERT(!req.supportsPersistentConnection());
|
2010-03-07 10:36:42 +00:00
|
|
|
req.redirectUri("http://host/file");
|
2008-12-15 15:38:07 +00:00
|
|
|
CPPUNIT_ASSERT(req.supportsPersistentConnection());
|
|
|
|
}
|
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
void RequestTest::testSetUri_ipv6()
|
2009-08-30 15:05:30 +00:00
|
|
|
{
|
|
|
|
Request req;
|
2010-03-07 10:36:42 +00:00
|
|
|
CPPUNIT_ASSERT(!req.setUri("http://[::1"));
|
|
|
|
CPPUNIT_ASSERT(req.setUri("http://[::1]"));
|
2009-08-30 15:05:30 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("::1"), req.getHost());
|
|
|
|
|
2010-03-07 10:36:42 +00:00
|
|
|
CPPUNIT_ASSERT(req.setUri("http://[::1]:8000/dir/file"));
|
2009-08-30 15:05:30 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("::1"), req.getHost());
|
|
|
|
CPPUNIT_ASSERT_EQUAL((uint16_t)8000, req.getPort());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("/dir"), req.getDir());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("file"), req.getFile());
|
|
|
|
CPPUNIT_ASSERT(req.isIPv6LiteralAddress());
|
|
|
|
}
|
|
|
|
|
|
|
|
void RequestTest::testGetURIHost()
|
|
|
|
{
|
|
|
|
Request req;
|
2010-03-07 10:36:42 +00:00
|
|
|
CPPUNIT_ASSERT(req.setUri("http://[::1]"));
|
2009-08-30 15:05:30 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("[::1]"), req.getURIHost());
|
|
|
|
}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
} // namespace aria2
|