diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2010-10-09 14:52:41 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2010-10-09 14:52:41 +0000 |
| commit | f816434d06c6bc66b2421d29c8d2ffecd04868ba (patch) | |
| tree | 269b2243114b08f98efadb6218bfbad31c4aa36a /test/HttpRequestTest.cc | |
| parent | b8f8a14937b76e3498a3a3acf381c0d6af641ab9 (diff) | |
2010-10-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added tests to HttpRequestTest about trailing slash of cookie
path.
* test/HttpRequestTest.cc
Diffstat (limited to 'test/HttpRequestTest.cc')
| -rw-r--r-- | test/HttpRequestTest.cc | 56 |
1 files changed, 41 insertions, 15 deletions
diff --git a/test/HttpRequestTest.cc b/test/HttpRequestTest.cc index 8f73ceb4..a2a4d1bc 100644 --- a/test/HttpRequestTest.cc +++ b/test/HttpRequestTest.cc @@ -381,21 +381,19 @@ void HttpRequestTest::testCreateRequest_with_cookie() (new PiecedSegment(1024*1024, p)); SharedHandle<FileEntry> fileEntry(new FileEntry("file", 1024*1024*10, 0)); - Cookie cookie1(createCookie("name1", "value1", "localhost", true, - "/archives", false)); - Cookie cookie2(createCookie("name2", "value2", "localhost", true, - "/archives/download", false)); - Cookie cookie3(createCookie("name3", "value3", "aria2.org", false, - "/archives/download", false)); - Cookie cookie4(createCookie("name4", "value4", "aria2.org", false, - "/archives/", true)); - - time_t now = time(0); + Cookie cookies[] = { + createCookie("name1", "value1", "localhost", true, "/archives", false), + createCookie("name2", "value2", "localhost", true, + "/archives/download", false), + createCookie("name3", "value3", "aria2.org", false, + "/archives/download", false), + createCookie("name4", "value4", "aria2.org", false, "/archives/", true), + createCookie("name5", "value5", "example.org", false, "/", false) + }; SharedHandle<CookieStorage> st(new CookieStorage()); - CPPUNIT_ASSERT(st->store(cookie1, now)); - CPPUNIT_ASSERT(st->store(cookie2, now)); - CPPUNIT_ASSERT(st->store(cookie3, now)); - CPPUNIT_ASSERT(st->store(cookie4, now)); + for(size_t i = 0; i < A2_ARRAY_LEN(cookies); ++i) { + CPPUNIT_ASSERT(st->store(cookies[i], 0)); + } HttpRequest httpRequest; @@ -460,7 +458,35 @@ void HttpRequestTest::testCreateRequest_with_cookie() "\r\n"; CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest()); - + + // The path of cookie4 ends with '/' + request->setUri("https://www.aria2.org/archives/aria2-1.0.0.tar.bz2"); + + expectedText = "GET /archives/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n" + "User-Agent: aria2\r\n" + "Accept: */*\r\n" + "Host: www.aria2.org\r\n" + "Pragma: no-cache\r\n" + "Cache-Control: no-cache\r\n" + "Connection: close\r\n" + "Cookie: name4=value4;\r\n" + "\r\n"; + + CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest()); + + request->setUri("http://example.org/aria2-1.0.0.tar.bz2"); + + expectedText = "GET /aria2-1.0.0.tar.bz2 HTTP/1.1\r\n" + "User-Agent: aria2\r\n" + "Accept: */*\r\n" + "Host: example.org\r\n" + "Pragma: no-cache\r\n" + "Cache-Control: no-cache\r\n" + "Connection: close\r\n" + "Cookie: name5=value5;\r\n" + "\r\n"; + + CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest()); } void HttpRequestTest::testCreateRequest_query() |
