On Sun, Jul 2, 2017 at 5:41 AM, Bjorn Reese via Boost
How would an example of receiving a chunked transfer using the synchronous API look? In pseudo-code, I want to do as follows:
establish connection while not closed read chunk print chunk
That's going to be be quite involved, you would need to subclass
beast::http::basic_parser and implement on_chunk to remember the chunk
size. It is not something that I recommend nor is it a common
use-case. HTTP applications are not supposed to care about the
boundaries between chunks since intermediates like proxies are allowed
to re-frame chunked message payloads. However, some applications may
wish to decode the chunk-extension and Beast handles that, but you
have to subclass beast::http::basic_parser for it.
Its possible that what you are really asking is how to read a message
payload incrementally? One of the examples performs a similar
operation:
http://vinniefalco.github.io/beast/beast/more_examples/http_relay.html
Something like this should achieve your goal (note, untested):
/* This function reads a message using a fixed size buffer to hold
portions of the body, and prints the body contents to a `std::ostream`.
*/
template<
bool isRequest,
class SyncReadStream,
class DynamicBuffer>
void
read_and_print_body(
std::ostream& os,
SyncReadStream& stream,
DynamicBuffer& buffer,
error_code& ec)
{
parser