From 6996f07f5f7b70c8644344658dde5d164d2b0da0 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 2 Apr 2010 14:16:10 +0000 Subject: 2010-04-02 Tatsuhiro Tsujikawa Don't send "Accept: default, gzip" by default. This is because some server responds with "Content-Encoding: gzip" for files which itself is gzipped file and aria2 inflates them. This is a problem if user don't want to inflate the file. Apparently this is server configuration error, but I cannot do anything about this. So turn this off. Added --http-accept-gzip option. If true is given to this option, aria2 sends 'Accept: deflate, gzip' request header and inflates response if remote server responds with 'Content-Encoding: gzip' or 'Content-Encoding: deflate'. This indicates we removed extension tgz hack in order not to inflate files with tgz extensions. * doc/aria2c.1.txt * src/HttpRequest.cc * src/HttpRequest.h * src/HttpRequestCommand.cc * src/HttpResponseCommand.cc * src/OptionHandlerFactory.cc * src/prefs.cc * src/prefs.h * src/usage_text.h * test/HttpRequestTest.cc --- test/HttpRequestTest.cc | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'test/HttpRequestTest.cc') diff --git a/test/HttpRequestTest.cc b/test/HttpRequestTest.cc index 5ef923f0..f1dd9a5f 100644 --- a/test/HttpRequestTest.cc +++ b/test/HttpRequestTest.cc @@ -719,20 +719,30 @@ void HttpRequestTest::testEnableAcceptEncoding() acceptEncodings += "deflate, gzip"; #endif // HAVE_LIBZ - std::string expectedText = + std::string expectedTextHead = "GET /archives/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n" "User-Agent: aria2\r\n" "Accept: */*\r\n"; - if(!acceptEncodings.empty()) { - expectedText += "Accept-Encoding: "+acceptEncodings+"\r\n"; - } - expectedText += + std::string expectedTextTail = "Host: localhost\r\n" "Pragma: no-cache\r\n" "Cache-Control: no-cache\r\n" "Connection: close\r\n" "\r\n"; + std::string expectedText = expectedTextHead; + expectedText += expectedTextTail; + CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest()); + + expectedText = expectedTextHead; + if(!acceptEncodings.empty()) { + expectedText += "Accept-Encoding: "; + expectedText += acceptEncodings; + expectedText += "\r\n"; + } + expectedText += expectedTextTail; + + httpRequest.enableAcceptGZip(); CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest()); } -- cgit