mirror of https://github.com/aria2/aria2
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.pull/1/head
parent
4016aa3948
commit
608009ec06
|
@ -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>
|
2007-03-28 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
To cache resolved hostname:
|
To cache resolved hostname:
|
||||||
|
|
|
@ -83,7 +83,7 @@ string HttpRequest::createRequest() const
|
||||||
}
|
}
|
||||||
requestLine +=
|
requestLine +=
|
||||||
string(" HTTP/1.1\r\n")+
|
string(" HTTP/1.1\r\n")+
|
||||||
"User-Agent: "+userAgent+"\r\n"+
|
"User-Agent: "+Util::urlencode(userAgent)+"\r\n"+
|
||||||
"Accept: */*\r\n"+ /* */
|
"Accept: */*\r\n"+ /* */
|
||||||
"Host: "+getHostText(getHost(), getPort())+"\r\n"+
|
"Host: "+getHostText(getHost(), getPort())+"\r\n"+
|
||||||
"Pragma: no-cache\r\n"+
|
"Pragma: no-cache\r\n"+
|
||||||
|
|
23
src/main.cc
23
src/main.cc
|
@ -649,19 +649,20 @@ int main(int argc, char* argv[]) {
|
||||||
logger->info("%s %s", PACKAGE, PACKAGE_VERSION);
|
logger->info("%s %s", PACKAGE, PACKAGE_VERSION);
|
||||||
logger->info("Logging started.");
|
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();
|
RequestFactoryHandle requestFactory = new RequestFactory();
|
||||||
requestFactory->setOption(op);
|
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);
|
RequestFactorySingletonHolder::instance(requestFactory);
|
||||||
|
|
||||||
Util::setGlobalSignalHandler(SIGPIPE, SIG_IGN, 0);
|
Util::setGlobalSignalHandler(SIGPIPE, SIG_IGN, 0);
|
||||||
|
|
|
@ -335,7 +335,7 @@ void HttpRequestTest::testCreateRequest_with_cookie()
|
||||||
string expectedText = "GET /archives/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
|
string expectedText = "GET /archives/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
|
||||||
"User-Agent: aria2\r\n"
|
"User-Agent: aria2\r\n"
|
||||||
"Accept: */*\r\n"
|
"Accept: */*\r\n"
|
||||||
"Host: localhost:80\r\n"
|
"Host: localhost\r\n"
|
||||||
"Pragma: no-cache\r\n"
|
"Pragma: no-cache\r\n"
|
||||||
"Cache-Control: no-cache\r\n"
|
"Cache-Control: no-cache\r\n"
|
||||||
"Cookie: name1=value1;\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"
|
expectedText = "GET /archives/download/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
|
||||||
"User-Agent: aria2\r\n"
|
"User-Agent: aria2\r\n"
|
||||||
"Accept: */*\r\n"
|
"Accept: */*\r\n"
|
||||||
"Host: localhost:80\r\n"
|
"Host: localhost\r\n"
|
||||||
"Pragma: no-cache\r\n"
|
"Pragma: no-cache\r\n"
|
||||||
"Cache-Control: no-cache\r\n"
|
"Cache-Control: no-cache\r\n"
|
||||||
"Cookie: name1=value1;name2=value2;\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"
|
expectedText = "GET /archives/download/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
|
||||||
"User-Agent: aria2\r\n"
|
"User-Agent: aria2\r\n"
|
||||||
"Accept: */*\r\n"
|
"Accept: */*\r\n"
|
||||||
"Host: tt.localhost:80\r\n"
|
"Host: tt.localhost\r\n"
|
||||||
"Pragma: no-cache\r\n"
|
"Pragma: no-cache\r\n"
|
||||||
"Cache-Control: no-cache\r\n"
|
"Cache-Control: no-cache\r\n"
|
||||||
"Cookie: name1=value1;name2=value2;name3=value3;\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"
|
expectedText = "GET /archives/download/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
|
||||||
"User-Agent: aria2\r\n"
|
"User-Agent: aria2\r\n"
|
||||||
"Accept: */*\r\n"
|
"Accept: */*\r\n"
|
||||||
"Host: tt.localhost:443\r\n"
|
"Host: tt.localhost\r\n"
|
||||||
"Pragma: no-cache\r\n"
|
"Pragma: no-cache\r\n"
|
||||||
"Cache-Control: no-cache\r\n"
|
"Cache-Control: no-cache\r\n"
|
||||||
"Cookie: name1=value1;name2=value2;name3=value3;name4=value4;\r\n"
|
"Cookie: name1=value1;name2=value2;name3=value3;name4=value4;\r\n"
|
||||||
|
|
Loading…
Reference in New Issue