mirror of https://github.com/aria2/aria2
Request: Remove previousUri_
Historically, the previousUri_ has different meaning from referer_, but in the course of development, they have the same value. This change remove previousUri_ in favor of referer_.pull/141/head
parent
667a4725e8
commit
3080af7370
|
@ -224,8 +224,8 @@ std::string HttpRequest::createRequest()
|
|||
val += base64::encode(authText.begin(), authText.end());
|
||||
builtinHds.push_back(std::make_pair("Authorization:", val));
|
||||
}
|
||||
if(!getPreviousURI().empty()) {
|
||||
builtinHds.push_back(std::make_pair("Referer:", getPreviousURI()));
|
||||
if(!request_->getReferer().empty()) {
|
||||
builtinHds.push_back(std::make_pair("Referer:", request_->getReferer()));
|
||||
}
|
||||
if(cookieStorage_) {
|
||||
std::string cookiesValue;
|
||||
|
@ -411,11 +411,6 @@ const std::string& HttpRequest::getQuery() const
|
|||
return request_->getQuery();
|
||||
}
|
||||
|
||||
const std::string& HttpRequest::getPreviousURI() const
|
||||
{
|
||||
return request_->getPreviousUri();
|
||||
}
|
||||
|
||||
std::string HttpRequest::getURIHost() const
|
||||
{
|
||||
return request_->getURIHost();
|
||||
|
|
|
@ -131,8 +131,6 @@ public:
|
|||
|
||||
const std::string& getQuery() const;
|
||||
|
||||
const std::string& getPreviousURI() const;
|
||||
|
||||
std::string getURIHost() const;
|
||||
|
||||
Range getRange() const;
|
||||
|
|
|
@ -84,7 +84,6 @@ bool Request::setUri(const std::string& uri) {
|
|||
}
|
||||
|
||||
bool Request::resetUri() {
|
||||
previousUri_ = referer_;
|
||||
supportsPersistentConnection_ = true;
|
||||
setConnectedAddrInfo(A2STR::NIL, A2STR::NIL, 0);
|
||||
return parseUri(uri_);
|
||||
|
@ -92,7 +91,7 @@ bool Request::resetUri() {
|
|||
|
||||
void Request::setReferer(const std::string& uri)
|
||||
{
|
||||
referer_ = previousUri_ = removeFragment(uri);
|
||||
referer_ = removeFragment(uri);
|
||||
}
|
||||
|
||||
bool Request::redirectUri(const std::string& uri) {
|
||||
|
|
|
@ -52,11 +52,7 @@ private:
|
|||
std::string uri_;
|
||||
std::string currentUri_;
|
||||
/**
|
||||
* URI previously requested to the server. This is used as Referer
|
||||
*/
|
||||
std::string previousUri_;
|
||||
/**
|
||||
* URI used as Referer in the initial request
|
||||
* URI used as Referer header field
|
||||
*/
|
||||
std::string referer_;
|
||||
std::string method_;
|
||||
|
@ -97,7 +93,6 @@ public:
|
|||
// Returns URI passed by setUri()
|
||||
const std::string& getUri() const { return uri_; }
|
||||
const std::string& getCurrentUri() const { return currentUri_; }
|
||||
const std::string& getPreviousUri() const { return previousUri_; }
|
||||
const std::string& getReferer() const { return referer_; }
|
||||
void setReferer(const std::string& uri);
|
||||
const std::string& getProtocol() const { return us_.protocol; }
|
||||
|
|
|
@ -55,7 +55,7 @@ void RequestTest::testSetUri1() {
|
|||
req.getUri());
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com/"),
|
||||
req.getCurrentUri());
|
||||
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getPreviousUri());
|
||||
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getReferer());
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
|
||||
CPPUNIT_ASSERT_EQUAL((uint16_t)80, req.getPort());
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("aria.rednoah.com"), req.getHost());
|
||||
|
@ -77,8 +77,6 @@ void RequestTest::testSetUri2() {
|
|||
// referer is unchaged
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com:8080"),
|
||||
req.getReferer());
|
||||
// previousUri must equal to referer;
|
||||
CPPUNIT_ASSERT_EQUAL(req.getReferer(), req.getPreviousUri());
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
|
||||
CPPUNIT_ASSERT_EQUAL((uint16_t)8080, req.getPort());
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("aria.rednoah.com"), req.getHost());
|
||||
|
@ -116,8 +114,6 @@ void RequestTest::testRedirectUri()
|
|||
// currentUri must be updated
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.co.jp/"),
|
||||
req.getCurrentUri());
|
||||
// previousUri is "" because no referer is set.
|
||||
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getPreviousUri());
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("aria.rednoah.co.jp"), req.getHost());
|
||||
CPPUNIT_ASSERT_EQUAL((uint16_t)80, req.getPort());
|
||||
|
@ -156,25 +152,12 @@ void RequestTest::testRedirectUri2()
|
|||
{
|
||||
Request req;
|
||||
req.setUri("http://aria.rednoah.com/download.html");
|
||||
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getPreviousUri());
|
||||
req.setReferer("http://aria.rednoah.com/");
|
||||
// previousUri is updated when referer is specified
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com/"),
|
||||
req.getPreviousUri());
|
||||
req.redirectUri("http://aria.rednoah.com/403.html");
|
||||
|
||||
// previousUri must not be changed in redirection
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com/"),
|
||||
req.getPreviousUri());
|
||||
// referer is unchagned
|
||||
// referer must not be changed in redirection
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com/"),
|
||||
req.getReferer());
|
||||
|
||||
req.redirectUri("http://aria.rednoah.com/error.html");
|
||||
|
||||
// previousUri must not be changed in redirection
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com/"),
|
||||
req.getPreviousUri());
|
||||
}
|
||||
|
||||
void RequestTest::testResetUri()
|
||||
|
@ -191,9 +174,6 @@ void RequestTest::testResetUri()
|
|||
(std::string("http://aria.rednoah.com:8080/aria2/index.html"),
|
||||
req.getUri());
|
||||
CPPUNIT_ASSERT_EQUAL(req.getUri(), req.getCurrentUri());
|
||||
// previousUri must equal to referer
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com:8080/"),
|
||||
req.getPreviousUri());
|
||||
// referer is unchanged
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com:8080/"),
|
||||
req.getReferer());
|
||||
|
|
Loading…
Reference in New Issue