| Home | Libraries | People | FAQ | More

##### http::basic_parser::body_limit

Set the limit on the payload body.

###### Synopsis

    void
    body_limit(
        std::uint64_t v);

###### Description

This function sets the maximum allowed size of the payload body, before any encodings except chunked have been removed. Depending on the message semantics, one of these cases will apply:

- The Content-Length is specified and exceeds the limit. In this case the result `http::body_limit` is returned immediately after the header is parsed.
- The Content-Length is unspecified and the chunked encoding is not specified as the last encoding. In this case the end of message is determined by the end of file indicator on the associated stream or input source. If a sufficient number of body payload octets are presented to the parser to exceed the configured limit, the parse fails with the result `http::body_limit`
- The Transfer-Encoding specifies the chunked encoding as the last encoding. In this case, when the number of payload body octets produced by removing the chunked encoding exceeds the configured limit, the parse fails with the result `http::body_limit`.

Setting the limit after any body octets have been parsed results in undefined behavior. The default limit is 1MB for requests and 8MB for responses.

###### Parameters

Name | Description
--- | ---
`v` | The payload body limit to set