From 884a139e725f4c3968929dca734eef6812cf2e6f Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 17 Oct 2007 16:26:51 +0000 Subject: 2007-10-18 Tatsuhiro Tsujikawa Added HTTP/1.1 keep alive and pipelining support. See --enable-http-keep-alive and --enable-http-pipelining option. * src/AbstractCommand.{h, cc}: Now it has one-to-many relation to Segment. * src/HttpDownloadCommand.{h, cc} * src/OptionHandlerFactory.cc * src/HttpConnection.{h, cc} * src/version_usage.cc * src/HttpInitiateConnectionCommand.cc * src/FtpInitiateConnectionCommand.cc * src/Segment.h * src/HttpRequestCommand.{h, cc} * src/option_processing.cc * src/prefs.h * src/HttpResponseCommand.cc * src/SegmentMan.{h, cc} * src/FtpNegotiateCommand.cc * src/HttpProxyResponseCommand.cc * src/Request.cc * src/HttpRequest.cc * src/DownloadCommand.cc * test/HttpRequestTest.cc * test/RequestTest.cc --- test/HttpRequestTest.cc | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test/HttpRequestTest.cc') diff --git a/test/HttpRequestTest.cc b/test/HttpRequestTest.cc index 002f2260..2388aace 100644 --- a/test/HttpRequestTest.cc +++ b/test/HttpRequestTest.cc @@ -248,6 +248,24 @@ void HttpRequestTest::testCreateRequest() CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest()); + request->setKeepAlive(true); + + expectedText = "GET http://localhost:8080/archives/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n" + "User-Agent: aria2\r\n" + "Accept: */*\r\n" + "Host: localhost:8080\r\n" + "Pragma: no-cache\r\n" + "Cache-Control: no-cache\r\n" + "Range: bytes=0-1048575\r\n" + "Proxy-Connection: Keep-Alive\r\n" + "Proxy-Authorization: Basic YXJpYTJwcm94eXVzZXI6YXJpYTJwcm94eXBhc3N3ZA==\r\n" + "Authorization: Basic YXJpYTJ1c2VyOmFyaWEycGFzc3dk\r\n" + "\r\n"; + + CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest()); + + request->setKeepAlive(false); + option->put(PREF_HTTP_PROXY_AUTH_ENABLED, V_FALSE); httpRequest.configure(option.get()); @@ -414,8 +432,18 @@ void HttpRequestTest::testCreateProxyRequest() string expectedText = "CONNECT localhost:80 HTTP/1.1\r\n" "User-Agent: aria2\r\n" + "Host: localhost:80\r\n" "Proxy-Connection: close\r\n" + "\r\n"; + + CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createProxyRequest()); + + request->setKeepAlive(true); + + expectedText = "CONNECT localhost:80 HTTP/1.1\r\n" + "User-Agent: aria2\r\n" "Host: localhost:80\r\n" + "Proxy-Connection: Keep-Alive\r\n" "\r\n"; CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createProxyRequest()); -- cgit