2010-01-22 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

aria2 now returns gzip compressed XML-RPC response if XML-RPC
	client accepts gzip content encoding.
	* src/A2STR.cc
	* src/A2STR.h
	* src/GZipEncoder.cc
	* src/GZipEncoder.h
	* src/HttpHeader.cc
	* src/HttpHeader.h
	* src/HttpServer.cc
	* src/HttpServer.h
	* src/HttpServerBodyCommand.cc
	* src/HttpServerCommand.cc
	* src/Makefile.am
	* src/XmlRpcResponse.cc
	* src/XmlRpcResponse.h
	* test/GZipEncoderTest.cc
	* test/Makefile.am
This commit is contained in:
Tatsuhiro Tsujikawa 2010-01-22 14:09:39 +00:00
parent 5d8864caed
commit 06a52cad02
18 changed files with 418 additions and 41 deletions

48
test/GZipEncoderTest.cc Normal file
View file

@ -0,0 +1,48 @@
#include "GZipEncoder.h"
#include <cppunit/extensions/HelperMacros.h>
#include "GZipDecoder.h"
#include "util.h"
namespace aria2 {
class GZipEncoderTest:public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(GZipEncoderTest);
CPPUNIT_TEST(testEncode);
CPPUNIT_TEST_SUITE_END();
public:
void testEncode();
};
CPPUNIT_TEST_SUITE_REGISTRATION(GZipEncoderTest);
void GZipEncoderTest::testEncode()
{
GZipEncoder encoder;
encoder.init();
std::vector<std::string> inputs;
inputs.push_back("Hello World");
inputs.push_back("9223372036854775807");
inputs.push_back("Fox");
encoder << inputs[0];
encoder << util::parseLLInt(inputs[1]);
encoder << inputs[2].c_str();
std::string gzippedData = encoder.str();
GZipDecoder decoder;
decoder.init();
std::string gunzippedData =
decoder.decode(reinterpret_cast<const unsigned char*>(gzippedData.data()),
gzippedData.size());
CPPUNIT_ASSERT(decoder.finished());
CPPUNIT_ASSERT_EQUAL(strjoin(inputs.begin(), inputs.end(), ""),
gunzippedData);
}
} // namespace aria2