فهرست منبع

2007-03-29 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

* src/HttpRequest.cc (createRequest): url-encode user-agent

* src/main.cc: Fixed the bug that prevents download if .netrc
doesn't exist.

Tatsuhiro Tsujikawa 18 سال پیش
والد
کامیت
608009ec06
4فایلهای تغییر یافته به همراه24 افزوده شده و 16 حذف شده
  1. 7 0
      ChangeLog
  2. 1 1
      src/HttpRequest.cc
  3. 12 11
      src/main.cc
  4. 4 4
      test/HttpRequestTest.cc

+ 7 - 0
ChangeLog

@@ -1,3 +1,10 @@
+2007-03-29  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
+	
+	* src/HttpRequest.cc (createRequest): url-encode user-agent
+
+	* src/main.cc: Fixed the bug that prevents download if .netrc
+	doesn't exist.
+
 2007-03-28  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 
 	To cache resolved hostname:

+ 1 - 1
src/HttpRequest.cc

@@ -83,7 +83,7 @@ string HttpRequest::createRequest() const
   }
   requestLine +=
     string(" HTTP/1.1\r\n")+
-    "User-Agent: "+userAgent+"\r\n"+
+    "User-Agent: "+Util::urlencode(userAgent)+"\r\n"+
     "Accept: */*\r\n"+        /* */
     "Host: "+getHostText(getHost(), getPort())+"\r\n"+
     "Pragma: no-cache\r\n"+

+ 12 - 11
src/main.cc

@@ -649,19 +649,20 @@ int main(int argc, char* argv[]) {
     logger->info("%s %s", PACKAGE, PACKAGE_VERSION);
     logger->info("Logging started.");
 
-    NetrcHandle netrc = 0;
-    File netrccf(op->get(PREF_NETRC_PATH));
-    mode_t mode = netrccf.mode();
-    if(mode&(S_IRWXG|S_IRWXO)) {
-      logger->notice(".netrc file %s does not have correct permissions. It should be 600. netrc support disabled.",
-		     op->get(PREF_NETRC_PATH).c_str());
-    } else {
-      netrc = new Netrc();
-      netrc->parse(op->get(PREF_NETRC_PATH));
-    }
     RequestFactoryHandle requestFactory = new RequestFactory();
     requestFactory->setOption(op);
-    requestFactory->setNetrc(netrc);
+    File netrccf(op->get(PREF_NETRC_PATH));
+    if(!op->getAsBool(PREF_NO_NETRC) && netrccf.isFile()) {
+      mode_t mode = netrccf.mode();
+      if(mode&(S_IRWXG|S_IRWXO)) {
+	logger->notice(".netrc file %s does not have correct permissions. It should be 600. netrc support disabled.",
+		       op->get(PREF_NETRC_PATH).c_str());
+      } else {
+	NetrcHandle netrc = new Netrc();
+	netrc->parse(op->get(PREF_NETRC_PATH));
+	requestFactory->setNetrc(netrc);
+      }
+    }
     RequestFactorySingletonHolder::instance(requestFactory);
 
     Util::setGlobalSignalHandler(SIGPIPE, SIG_IGN, 0);

+ 4 - 4
test/HttpRequestTest.cc

@@ -335,7 +335,7 @@ void HttpRequestTest::testCreateRequest_with_cookie()
   string expectedText = "GET /archives/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
     "User-Agent: aria2\r\n"
     "Accept: */*\r\n"
-    "Host: localhost:80\r\n"
+    "Host: localhost\r\n"
     "Pragma: no-cache\r\n"
     "Cache-Control: no-cache\r\n"
     "Cookie: name1=value1;\r\n"
@@ -348,7 +348,7 @@ void HttpRequestTest::testCreateRequest_with_cookie()
   expectedText = "GET /archives/download/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
     "User-Agent: aria2\r\n"
     "Accept: */*\r\n"
-    "Host: localhost:80\r\n"
+    "Host: localhost\r\n"
     "Pragma: no-cache\r\n"
     "Cache-Control: no-cache\r\n"
     "Cookie: name1=value1;name2=value2;\r\n"
@@ -361,7 +361,7 @@ void HttpRequestTest::testCreateRequest_with_cookie()
   expectedText = "GET /archives/download/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
     "User-Agent: aria2\r\n"
     "Accept: */*\r\n"
-    "Host: tt.localhost:80\r\n"
+    "Host: tt.localhost\r\n"
     "Pragma: no-cache\r\n"
     "Cache-Control: no-cache\r\n"
     "Cookie: name1=value1;name2=value2;name3=value3;\r\n"
@@ -374,7 +374,7 @@ void HttpRequestTest::testCreateRequest_with_cookie()
   expectedText = "GET /archives/download/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
     "User-Agent: aria2\r\n"
     "Accept: */*\r\n"
-    "Host: tt.localhost:443\r\n"
+    "Host: tt.localhost\r\n"
     "Pragma: no-cache\r\n"
     "Cache-Control: no-cache\r\n"
     "Cookie: name1=value1;name2=value2;name3=value3;name4=value4;\r\n"