A very simple, fast, multithreaded, platform independent HTTP and HTTPS server and client library implemented using C++11 and Boost.Asio. Created to be an easy way to make REST resources available from C++ applications.
Thank you @whyuu , but it seems that you have been using an older version. Please try the latest master, issues with the chunked transfer encoding was fixed a little while back.
I find a bug when reading chunked data. I get a wrong result when data has only one byte.
I changed it by modify functions
if (tmp_streambuf->size() >= config.max_response_streambuf_size) { session->callback(session->connection, make_error_code::make_error_code(errc::message_size)); return; } // Move excess read data from session->response->streambuf to chunked_streambuf if (session->response->streambuf.size() > 0) { std::ostream chunked_stream(chunked_streambuf.get()); chunked_stream << &session->response->streambuf; ....
if(length > 0) { std::ostream tmp_stream(tmp_streambuf.get()); std::unique_ptr<char[]> buffer(new char[length]); chunked_stream.read(buffer.get(), static_cast(length));
tmp_stream.write(buffer.get(), static_cast(length));
}
... }
void read(const std::shared_ptr &session) {
....
else if((header_it = session->response->header.find("Transfer-Encoding")) != session->response->header.end() && header_it->second == "chunked") {
auto tmp_streambuf = std::make_shared();
// chunked_streambuf is needed as new read buffer with its size adjusted depending on the size of tmp_streambuf
auto chunked_streambuf = std::make_shared(config.max_response_streambuf_size - tmp_streambuf->size());
this->read_chunked(session, chunked_streambuf, tmp_streambuf);
}
...
}