Browse Source

2007-10-12 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

	Do not send referer when redirected.
	* src/Request.cc (redirectUrl)
	* test/RequestTest.cc
	* test/HttpRequestTest.cc
Tatsuhiro Tsujikawa 18 years ago
parent
commit
1d5834a6ca
4 changed files with 14 additions and 8 deletions
  1. 7 0
      ChangeLog
  2. 1 1
      src/Request.cc
  3. 0 1
      test/HttpRequestTest.cc
  4. 6 6
      test/RequestTest.cc

+ 7 - 0
ChangeLog

@@ -1,3 +1,10 @@
+2007-10-12  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
+
+	Do not send referer when redirected.
+	* src/Request.cc (redirectUrl)
+	* test/RequestTest.cc
+	* test/HttpRequestTest.cc
+
 2007-10-12  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 
 	Implemented BitTorrent/http/ftp integrated download.

+ 1 - 1
src/Request.cc

@@ -60,7 +60,7 @@ bool Request::resetUrl() {
 }
 
 bool Request::redirectUrl(const string& url) {
-  previousUrl = currentUrl;
+  previousUrl = "";
   return parseUrl(url);
 }
 

+ 0 - 1
test/HttpRequestTest.cc

@@ -171,7 +171,6 @@ void HttpRequestTest::testCreateRequest()
     "Cache-Control: no-cache\r\n"
     "Connection: close\r\n"
     "Range: bytes=1048576-\r\n"
-    "Referer: http://localhost:8080/archives/aria2-1.0.0.tar.bz2\r\n"
     "\r\n";
 
   CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest());

+ 6 - 6
test/RequestTest.cc

@@ -228,8 +228,8 @@ void RequestTest::testRedirectUrl() {
 		       req.getUrl());
   // currentUrl must be updated
   CPPUNIT_ASSERT_EQUAL(string("http://aria.rednoah.co.jp/"), req.getCurrentUrl());
-  // previousUrl must be updated
-  CPPUNIT_ASSERT_EQUAL(string("http://aria.rednoah.com:8080/aria2/index.html"), req.getPreviousUrl());
+  // previousUrl must be "" when redirection
+  CPPUNIT_ASSERT_EQUAL(string(""), req.getPreviousUrl());
   CPPUNIT_ASSERT_EQUAL(string("http"), req.getProtocol());
   CPPUNIT_ASSERT_EQUAL(string("aria.rednoah.co.jp"), req.getHost());
   CPPUNIT_ASSERT_EQUAL((int32_t)80, req.getPort());
@@ -246,15 +246,15 @@ void RequestTest::testRedirectUrl2() {
   CPPUNIT_ASSERT_EQUAL(string("http://aria.rednoah.com/"), req.getPreviousUrl());
   bool v2 = req.redirectUrl("http://aria.rednoah.com/403.html");
 
-  // previousUrl is updated
-  CPPUNIT_ASSERT_EQUAL(string("http://aria.rednoah.com/download.html"), req.getPreviousUrl());
+  // previousUrl must be "" when redirection
+  CPPUNIT_ASSERT_EQUAL(string(""), req.getPreviousUrl());
   // referer is unchagned
   CPPUNIT_ASSERT_EQUAL(string("http://aria.rednoah.com/"), req.getReferer());
 
   bool v3 = req.redirectUrl("http://aria.rednoah.com/error.html");
 
-  // previousUrl is update
-  CPPUNIT_ASSERT_EQUAL(string("http://aria.rednoah.com/403.html"), req.getPreviousUrl());
+  // previousUrl must be "" when redirection
+  CPPUNIT_ASSERT_EQUAL(string(""), req.getPreviousUrl());
 }
   
 void RequestTest::testResetUrl() {