2010-04-02 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

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
This commit is contained in:
Tatsuhiro Tsujikawa
2010-04-02 14:16:10 +00:00
parent 5cc28b2d80
commit 6996f07f5f
13 changed files with 153 additions and 26 deletions

View File

@@ -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());
}