Skip to content

fix lost last chunk when there is two chunks in one read

Ole Christian Eidheim requested to merge k1988:master into master

Created by: k1988

when i request some json files, the response sometimes with header "Transfer-Encoding: chunked"。 if the response is mini , the reqeust is block, the result is after readed one chunked, the rest bytes of chunked_streambuf is be discarded。

Test Enviroment:

  • Win10 64
  • Ngix 1.8
  • VS2017
  • Boost 1.65

Test code:

void testChunkJson() {
	// do emu
	HttpClient client("192.168.0.101:8080");

	// Synchronous request examples
	try {
		// decode gzip
 		auto r2 = client.request("GET", "/test/chunk.json", "", SimpleWeb::CaseInsensitiveMultimap({ std::make_pair("Accept-Encoding","gzip, deflate") }));
		std::stringstream ss_decomp;
		boost::iostreams::filtering_istream in;
		in.push(boost::iostreams::gzip_decompressor());
		in.push(r2->content);
		boost::iostreams::copy(in, ss_decomp);
	}
	catch (const SimpleWeb::system_error &e) {
		cerr << "Client request error: " << e.what() << endl;
	}
}

Merge request reports

Loading