mirror of
https://github.com/aria2/aria2.git
synced 2026-04-02 10:55:00 +00:00
2008-04-20 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added --header option. You can specify any number of additional HTTP headers like: aria2 --header="X-A: 300" --header="X-B: 900" http://host/file Unlike other commad-line option, you can use --header option multiple times. * src/HelpItemFactory.cc * src/HttpRequest.{cc, h} * src/HttpRequestCommand.cc * src/OptionHandlerFactory.cc * src/OptionHandlerImpl.h * src/option_processing.cc * src/prefs.h * src/usage_text.h * test/HttpRequestTest.cc (testUserHeaders)
This commit is contained in:
@@ -22,6 +22,7 @@ class HttpRequestTest : public CppUnit::TestFixture {
|
||||
CPPUNIT_TEST(testCreateProxyRequest);
|
||||
CPPUNIT_TEST(testIsRangeSatisfied);
|
||||
CPPUNIT_TEST(testUserAgent);
|
||||
CPPUNIT_TEST(testUserHeaders);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
private:
|
||||
|
||||
@@ -36,6 +37,7 @@ public:
|
||||
void testCreateProxyRequest();
|
||||
void testIsRangeSatisfied();
|
||||
void testUserAgent();
|
||||
void testUserHeaders();
|
||||
};
|
||||
|
||||
|
||||
@@ -557,4 +559,28 @@ void HttpRequestTest::testUserAgent()
|
||||
CPPUNIT_ASSERT_EQUAL(expectedTextForProxy, httpRequest.createProxyRequest());
|
||||
}
|
||||
|
||||
void HttpRequestTest::testUserHeaders()
|
||||
{
|
||||
SharedHandle<Request> request(new Request());
|
||||
request->setUrl("http://localhost/archives/aria2-1.0.0.tar.bz2");
|
||||
|
||||
HttpRequest httpRequest;
|
||||
httpRequest.setRequest(request);
|
||||
httpRequest.setUserHeaders("X-ARIA2: v0.13\nX-ARIA2-DISTRIBUTE: enabled\n");
|
||||
|
||||
std::string expectedText = "GET /archives/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
|
||||
"User-Agent: aria2\r\n"
|
||||
"Accept: */*\r\n"
|
||||
"Host: localhost\r\n"
|
||||
"Pragma: no-cache\r\n"
|
||||
"Cache-Control: no-cache\r\n"
|
||||
"Connection: close\r\n"
|
||||
"X-ARIA2: v0.13\r\n"
|
||||
"X-ARIA2-DISTRIBUTE: enabled\r\n"
|
||||
"\r\n";
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest());
|
||||
}
|
||||
|
||||
|
||||
} // namespace aria2
|
||||
|
||||
Reference in New Issue
Block a user