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());
|
val += base64::encode(authText.begin(), authText.end());
|
||||||
builtinHds.push_back(std::make_pair("Authorization:", val));
|
builtinHds.push_back(std::make_pair("Authorization:", val));
|
||||||
}
|
}
|
||||||
if(!getPreviousURI().empty()) {
|
if(!request_->getReferer().empty()) {
|
||||||
builtinHds.push_back(std::make_pair("Referer:", getPreviousURI()));
|
builtinHds.push_back(std::make_pair("Referer:", request_->getReferer()));
|
||||||
}
|
}
|
||||||
if(cookieStorage_) {
|
if(cookieStorage_) {
|
||||||
std::string cookiesValue;
|
std::string cookiesValue;
|
||||||
|
@ -411,11 +411,6 @@ const std::string& HttpRequest::getQuery() const
|
||||||
return request_->getQuery();
|
return request_->getQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& HttpRequest::getPreviousURI() const
|
|
||||||
{
|
|
||||||
return request_->getPreviousUri();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string HttpRequest::getURIHost() const
|
std::string HttpRequest::getURIHost() const
|
||||||
{
|
{
|
||||||
return request_->getURIHost();
|
return request_->getURIHost();
|
||||||
|
|
|
@ -131,8 +131,6 @@ public:
|
||||||
|
|
||||||
const std::string& getQuery() const;
|
const std::string& getQuery() const;
|
||||||
|
|
||||||
const std::string& getPreviousURI() const;
|
|
||||||
|
|
||||||
std::string getURIHost() const;
|
std::string getURIHost() const;
|
||||||
|
|
||||||
Range getRange() const;
|
Range getRange() const;
|
||||||
|
|
|
@ -84,7 +84,6 @@ bool Request::setUri(const std::string& uri) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Request::resetUri() {
|
bool Request::resetUri() {
|
||||||
previousUri_ = referer_;
|
|
||||||
supportsPersistentConnection_ = true;
|
supportsPersistentConnection_ = true;
|
||||||
setConnectedAddrInfo(A2STR::NIL, A2STR::NIL, 0);
|
setConnectedAddrInfo(A2STR::NIL, A2STR::NIL, 0);
|
||||||
return parseUri(uri_);
|
return parseUri(uri_);
|
||||||
|
@ -92,7 +91,7 @@ bool Request::resetUri() {
|
||||||
|
|
||||||
void Request::setReferer(const std::string& uri)
|
void Request::setReferer(const std::string& uri)
|
||||||
{
|
{
|
||||||
referer_ = previousUri_ = removeFragment(uri);
|
referer_ = removeFragment(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Request::redirectUri(const std::string& uri) {
|
bool Request::redirectUri(const std::string& uri) {
|
||||||
|
|
|
@ -52,11 +52,7 @@ private:
|
||||||
std::string uri_;
|
std::string uri_;
|
||||||
std::string currentUri_;
|
std::string currentUri_;
|
||||||
/**
|
/**
|
||||||
* URI previously requested to the server. This is used as Referer
|
* URI used as Referer header field
|
||||||
*/
|
|
||||||
std::string previousUri_;
|
|
||||||
/**
|
|
||||||
* URI used as Referer in the initial request
|
|
||||||
*/
|
*/
|
||||||
std::string referer_;
|
std::string referer_;
|
||||||
std::string method_;
|
std::string method_;
|
||||||
|
@ -97,7 +93,6 @@ public:
|
||||||
// Returns URI passed by setUri()
|
// Returns URI passed by setUri()
|
||||||
const std::string& getUri() const { return uri_; }
|
const std::string& getUri() const { return uri_; }
|
||||||
const std::string& getCurrentUri() const { return currentUri_; }
|
const std::string& getCurrentUri() const { return currentUri_; }
|
||||||
const std::string& getPreviousUri() const { return previousUri_; }
|
|
||||||
const std::string& getReferer() const { return referer_; }
|
const std::string& getReferer() const { return referer_; }
|
||||||
void setReferer(const std::string& uri);
|
void setReferer(const std::string& uri);
|
||||||
const std::string& getProtocol() const { return us_.protocol; }
|
const std::string& getProtocol() const { return us_.protocol; }
|
||||||
|
|
|
@ -55,7 +55,7 @@ void RequestTest::testSetUri1() {
|
||||||
req.getUri());
|
req.getUri());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com/"),
|
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com/"),
|
||||||
req.getCurrentUri());
|
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(std::string("http"), req.getProtocol());
|
||||||
CPPUNIT_ASSERT_EQUAL((uint16_t)80, req.getPort());
|
CPPUNIT_ASSERT_EQUAL((uint16_t)80, req.getPort());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("aria.rednoah.com"), req.getHost());
|
CPPUNIT_ASSERT_EQUAL(std::string("aria.rednoah.com"), req.getHost());
|
||||||
|
@ -77,8 +77,6 @@ void RequestTest::testSetUri2() {
|
||||||
// referer is unchaged
|
// referer is unchaged
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com:8080"),
|
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com:8080"),
|
||||||
req.getReferer());
|
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(std::string("http"), req.getProtocol());
|
||||||
CPPUNIT_ASSERT_EQUAL((uint16_t)8080, req.getPort());
|
CPPUNIT_ASSERT_EQUAL((uint16_t)8080, req.getPort());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("aria.rednoah.com"), req.getHost());
|
CPPUNIT_ASSERT_EQUAL(std::string("aria.rednoah.com"), req.getHost());
|
||||||
|
@ -116,8 +114,6 @@ void RequestTest::testRedirectUri()
|
||||||
// currentUri must be updated
|
// currentUri must be updated
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.co.jp/"),
|
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.co.jp/"),
|
||||||
req.getCurrentUri());
|
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("http"), req.getProtocol());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("aria.rednoah.co.jp"), req.getHost());
|
CPPUNIT_ASSERT_EQUAL(std::string("aria.rednoah.co.jp"), req.getHost());
|
||||||
CPPUNIT_ASSERT_EQUAL((uint16_t)80, req.getPort());
|
CPPUNIT_ASSERT_EQUAL((uint16_t)80, req.getPort());
|
||||||
|
@ -156,25 +152,12 @@ void RequestTest::testRedirectUri2()
|
||||||
{
|
{
|
||||||
Request req;
|
Request req;
|
||||||
req.setUri("http://aria.rednoah.com/download.html");
|
req.setUri("http://aria.rednoah.com/download.html");
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getPreviousUri());
|
|
||||||
req.setReferer("http://aria.rednoah.com/");
|
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");
|
req.redirectUri("http://aria.rednoah.com/403.html");
|
||||||
|
|
||||||
// previousUri must not be changed in redirection
|
// referer must not be changed in redirection
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com/"),
|
|
||||||
req.getPreviousUri());
|
|
||||||
// referer is unchagned
|
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com/"),
|
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com/"),
|
||||||
req.getReferer());
|
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()
|
void RequestTest::testResetUri()
|
||||||
|
@ -191,9 +174,6 @@ void RequestTest::testResetUri()
|
||||||
(std::string("http://aria.rednoah.com:8080/aria2/index.html"),
|
(std::string("http://aria.rednoah.com:8080/aria2/index.html"),
|
||||||
req.getUri());
|
req.getUri());
|
||||||
CPPUNIT_ASSERT_EQUAL(req.getUri(), req.getCurrentUri());
|
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
|
// referer is unchanged
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com:8080/"),
|
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com:8080/"),
|
||||||
req.getReferer());
|
req.getReferer());
|
||||||
|
|
Loading…
Reference in New Issue