mirror of https://github.com/aria2/aria2
2010-01-26 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Handle redirected URI which is not properly percent encoded. * src/Request.cc * test/RequestTest.ccpull/1/head
parent
69850ada49
commit
60c16887e6
|
@ -1,3 +1,9 @@
|
||||||
|
2010-01-26 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Handle redirected URI which is not properly percent encoded.
|
||||||
|
* src/Request.cc
|
||||||
|
* test/RequestTest.cc
|
||||||
|
|
||||||
2010-01-25 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2010-01-25 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Fixed the bug that causes segmentaiton fault when aria2 sees '404
|
Fixed the bug that causes segmentaiton fault when aria2 sees '404
|
||||||
|
|
|
@ -127,19 +127,21 @@ bool Request::redirectUrl(const std::string& url) {
|
||||||
_previousUrl = A2STR::NIL;
|
_previousUrl = A2STR::NIL;
|
||||||
_supportsPersistentConnection = true;
|
_supportsPersistentConnection = true;
|
||||||
++_redirectCount;
|
++_redirectCount;
|
||||||
|
std::string redirectedUrl;
|
||||||
if(url.find("://") == std::string::npos) {
|
if(url.find("://") == std::string::npos) {
|
||||||
// rfc2616 requires absolute URI should be provided by Location header
|
// rfc2616 requires absolute URI should be provided by Location header
|
||||||
// field, but some servers don't obey this rule.
|
// field, but some servers don't obey this rule.
|
||||||
if(util::startsWith(url, "/")) {
|
if(util::startsWith(url, "/")) {
|
||||||
// abosulute path
|
// abosulute path
|
||||||
return parseUrl(strconcat(_protocol, "://", _host, url));
|
redirectedUrl = strconcat(_protocol, "://", _host, url);
|
||||||
} else {
|
} else {
|
||||||
// relative path
|
// relative path
|
||||||
return parseUrl(strconcat(_protocol, "://", _host, _dir, "/", url));
|
redirectedUrl = strconcat(_protocol, "://", _host, _dir, "/", url);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return parseUrl(url);
|
redirectedUrl = url;
|
||||||
}
|
}
|
||||||
|
return parseUrl(urlencode(redirectedUrl));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Request::parseUrl(const std::string& url) {
|
bool Request::parseUrl(const std::string& url) {
|
||||||
|
|
|
@ -362,6 +362,11 @@ void RequestTest::testRedirectUrl() {
|
||||||
"relativepath/to/file"),
|
"relativepath/to/file"),
|
||||||
req.getCurrentUrl());
|
req.getCurrentUrl());
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)3, req.getRedirectCount());
|
CPPUNIT_ASSERT_EQUAL((unsigned int)3, req.getRedirectCount());
|
||||||
|
|
||||||
|
// White space in path
|
||||||
|
CPPUNIT_ASSERT(req.redirectUrl("http://example.org/white space"));
|
||||||
|
CPPUNIT_ASSERT_EQUAL(std::string("http://example.org/white%20space"),
|
||||||
|
req.getCurrentUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
void RequestTest::testRedirectUrl2() {
|
void RequestTest::testRedirectUrl2() {
|
||||||
|
|
Loading…
Reference in New Issue