mirror of
https://github.com/aria2/aria2.git
synced 2025-04-04 21:17:41 +03:00
2008-05-05 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Reimplemented transparent metalink using Accept request header. * src/HttpRequest.cc * src/HttpRequest.h * src/HttpRequestCommand.cc * src/Metalink2RequestGroup.cc * src/RequestGroup.cc * src/RequestGroup.h * test/HttpRequestTest.cc
This commit is contained in:
parent
b892b54e4b
commit
f596de9eec
8 changed files with 104 additions and 15 deletions
|
@ -7,6 +7,7 @@
|
|||
#include "Request.h"
|
||||
#include "CookieBox.h"
|
||||
#include "Option.h"
|
||||
#include "array_fun.h"
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
namespace aria2 {
|
||||
|
@ -24,6 +25,7 @@ class HttpRequestTest : public CppUnit::TestFixture {
|
|||
CPPUNIT_TEST(testIsRangeSatisfied);
|
||||
CPPUNIT_TEST(testUserAgent);
|
||||
CPPUNIT_TEST(testAddHeader);
|
||||
CPPUNIT_TEST(testAddAcceptType);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
private:
|
||||
|
||||
|
@ -40,6 +42,7 @@ public:
|
|||
void testIsRangeSatisfied();
|
||||
void testUserAgent();
|
||||
void testAddHeader();
|
||||
void testAddAcceptType();
|
||||
};
|
||||
|
||||
|
||||
|
@ -641,5 +644,29 @@ void HttpRequestTest::testAddHeader()
|
|||
CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest());
|
||||
}
|
||||
|
||||
void HttpRequestTest::testAddAcceptType()
|
||||
{
|
||||
std::string acceptTypes[] = { "cream/custard",
|
||||
"muffin/chocolate" };
|
||||
|
||||
SharedHandle<Request> request(new Request());
|
||||
request->setUrl("http://localhost/archives/aria2-1.0.0.tar.bz2");
|
||||
|
||||
HttpRequest httpRequest;
|
||||
httpRequest.setRequest(request);
|
||||
httpRequest.addAcceptType(&acceptTypes[0], &acceptTypes[arrayLength(acceptTypes)]);
|
||||
|
||||
std::string expectedText =
|
||||
"GET /archives/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
|
||||
"User-Agent: aria2\r\n"
|
||||
"Accept: */*,cream/custard,muffin/chocolate\r\n"
|
||||
"Host: localhost\r\n"
|
||||
"Pragma: no-cache\r\n"
|
||||
"Cache-Control: no-cache\r\n"
|
||||
"Connection: close\r\n"
|
||||
"\r\n";
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest());
|
||||
}
|
||||
|
||||
} // namespace aria2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue