Beast: Add parser::limit

Created on 28 Jun 2017  路  4Comments  路  Source: boostorg/beast

From pre-Boost-review feedback

Feature

Most helpful comment

Yeah, sorry you are right, I missed that page, I reached my goal this way:

boost::beast::flat_buffer buffer;
http::response_parser<http::string_body> parser;
parser.body_limit(16 * 1024 * 1024);
http::read(socket, buffer, parser);
std::cout << parser.get().body() << "\n";

thank you again

All 4 comments

Added body_limit and header_limit

Hi Vinnie, sorry it's not clear to me the simplest way to customise the body limits, at the moment I'm reading data in a very easy way:

boost::beast::flat_buffer buffer; http::response<http::string_body> res; http::read(socket, buffer, res);
But my payload exceeded 8MiB. It seems that I need to define a custom parser, does I really need to do this? and suppose I do so, how my custom parser (as described in https://www.boost.org/doc/libs/develop/libs/beast/doc/html/beast/ref/boost__beast__http__basic_parser.html) fits in my code?

I successfully used your great library in many standard situation, but I struggled a bit in those kind of customisation and I fear to follow too much complex way to just increase a buffer.

Thank you for your time!

The documentation explains how to use the parser-oriented interfaces and provides example code:
https://www.boost.org/doc/libs/1_66_0/libs/beast/doc/html/beast/using_http/parser_stream_operations.html

Yeah, sorry you are right, I missed that page, I reached my goal this way:

boost::beast::flat_buffer buffer;
http::response_parser<http::string_body> parser;
parser.body_limit(16 * 1024 * 1024);
http::read(socket, buffer, parser);
std::cout << parser.get().body() << "\n";

thank you again

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xemwebe picture xemwebe  路  6Comments

JanVerschaeren picture JanVerschaeren  路  6Comments

chrgrd picture chrgrd  路  4Comments

inetic picture inetic  路  4Comments

shuras109 picture shuras109  路  6Comments