| Home | Libraries | People | FAQ | More

##### http::parser::on_chunk_header

Set a callback to be invoked on each chunk header.

###### Synopsis

    template<
        class Callback>
    void
    on_chunk_header(
        Callback& cb);

###### Description

The callback will be invoked once for every chunk in the message payload, as well as once for the last chunk. The invocation happens after the chunk header is available but before any body octets have been parsed. The extensions are provided in raw, validated form, use `http::basic_chunk_extensions::parse` to parse the extensions into a structured container for easier access. The implementation type-erases the callback without requiring a dynamic allocation. For this reason, the callback object is passed by a non-constant reference.

###### Example

    auto callback =
        [](std::uint64_t size, string_view extensions, error_code& ec)
        {
            //...
        };
    parser.on_chunk_header(callback);

###### Parameters

Name | Description
--- | ---

`cb`

The function to set, which must be invocable with this equivalent signature:

    void
    on_chunk_header(
        std::uint64_t size,         // Size of the chunk, zero for the last chunk
        string_view extensions,     // The chunk-extensions in raw form
        error_code& ec);            // May be set by the callback to indicate an error