mirror of
https://github.com/aria2/aria2.git
synced 2025-04-06 14:07:37 +03:00
Use request URI as referer if --referer="*" is given
This commit is contained in:
parent
58c047a4a8
commit
87af7c32c6
3 changed files with 24 additions and 2 deletions
|
@ -170,7 +170,12 @@ FileEntry::getRequest
|
||||||
req.reset();
|
req.reset();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
req->setReferer(util::percentEncodeMini(referer));
|
if(referer == "*") {
|
||||||
|
// Assuming uri has already been percent-encoded.
|
||||||
|
req->setReferer(uri);
|
||||||
|
} else {
|
||||||
|
req->setReferer(util::percentEncodeMini(referer));
|
||||||
|
}
|
||||||
req->setMethod(method);
|
req->setMethod(method);
|
||||||
spentUris_.push_back(uri);
|
spentUris_.push_back(uri);
|
||||||
inFlightRequests_.insert(req);
|
inFlightRequests_.insert(req);
|
||||||
|
|
|
@ -94,7 +94,9 @@
|
||||||
#define TEXT_PROXY_METHOD \
|
#define TEXT_PROXY_METHOD \
|
||||||
_(" --proxy-method=METHOD Set the method to use in proxy request.")
|
_(" --proxy-method=METHOD Set the method to use in proxy request.")
|
||||||
#define TEXT_REFERER \
|
#define TEXT_REFERER \
|
||||||
_(" --referer=REFERER Set Referer. This affects all URLs.")
|
_(" --referer=REFERER Set Referer. This affects all URLs. If \"*\" is\n" \
|
||||||
|
" given, each request URI is used as a referer.\n" \
|
||||||
|
" This may be useful when used with -P option.")
|
||||||
#define TEXT_FTP_USER \
|
#define TEXT_FTP_USER \
|
||||||
_(" --ftp-user=USER Set FTP user. This affects all URLs.")
|
_(" --ftp-user=USER Set FTP user. This affects all URLs.")
|
||||||
#define TEXT_FTP_PASSWD \
|
#define TEXT_FTP_PASSWD \
|
||||||
|
|
|
@ -15,6 +15,7 @@ class FileEntryTest : public CppUnit::TestFixture {
|
||||||
CPPUNIT_TEST(testGetRequest);
|
CPPUNIT_TEST(testGetRequest);
|
||||||
CPPUNIT_TEST(testGetRequest_withoutUriReuse);
|
CPPUNIT_TEST(testGetRequest_withoutUriReuse);
|
||||||
CPPUNIT_TEST(testGetRequest_withUniqueProtocol);
|
CPPUNIT_TEST(testGetRequest_withUniqueProtocol);
|
||||||
|
CPPUNIT_TEST(testGetRequest_withReferer);
|
||||||
CPPUNIT_TEST(testReuseUri);
|
CPPUNIT_TEST(testReuseUri);
|
||||||
CPPUNIT_TEST(testAddUri);
|
CPPUNIT_TEST(testAddUri);
|
||||||
CPPUNIT_TEST(testAddUris);
|
CPPUNIT_TEST(testAddUris);
|
||||||
|
@ -30,6 +31,7 @@ public:
|
||||||
void testGetRequest();
|
void testGetRequest();
|
||||||
void testGetRequest_withoutUriReuse();
|
void testGetRequest_withoutUriReuse();
|
||||||
void testGetRequest_withUniqueProtocol();
|
void testGetRequest_withUniqueProtocol();
|
||||||
|
void testGetRequest_withReferer();
|
||||||
void testReuseUri();
|
void testReuseUri();
|
||||||
void testAddUri();
|
void testAddUri();
|
||||||
void testAddUris();
|
void testAddUris();
|
||||||
|
@ -184,6 +186,19 @@ void FileEntryTest::testGetRequest_withUniqueProtocol()
|
||||||
fileEntry->getRemainingUris()[1]);
|
fileEntry->getRemainingUris()[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FileEntryTest::testGetRequest_withReferer()
|
||||||
|
{
|
||||||
|
SharedHandle<FileEntry> fileEntry = createFileEntry();
|
||||||
|
SharedHandle<InorderURISelector> selector(new InorderURISelector());
|
||||||
|
std::vector<std::pair<size_t, std::string> > usedHosts;
|
||||||
|
SharedHandle<Request> req =
|
||||||
|
fileEntry->getRequest(selector, true, usedHosts, "http://referer");
|
||||||
|
CPPUNIT_ASSERT_EQUAL(std::string("http://referer"), req->getReferer());
|
||||||
|
// URI is used as referer if "*" is given.
|
||||||
|
req = fileEntry->getRequest(selector, true, usedHosts, "*");
|
||||||
|
CPPUNIT_ASSERT_EQUAL(req->getUri(), req->getReferer());
|
||||||
|
}
|
||||||
|
|
||||||
void FileEntryTest::testReuseUri()
|
void FileEntryTest::testReuseUri()
|
||||||
{
|
{
|
||||||
SharedHandle<InorderURISelector> selector(new InorderURISelector());
|
SharedHandle<InorderURISelector> selector(new InorderURISelector());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue