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:
Tatsuhiro Tsujikawa
2008-04-20 06:30:44 +00:00
parent c1c5e7369f
commit 3eb74629cb
11 changed files with 98 additions and 1 deletions

View File

@@ -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