Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

FieldsWriter

A FieldsWriter provides a algorithm to obtain a sequence of buffers representing the complete serialized HTTP/1 header for a set of fields. The implementation constructs an instance of this type when needed, and calls into it once to retrieve the buffers.

Associated Types
Requirements
[Warning] Warning

These requirements may undergo non-backward compatible changes in subsequent versions.

In this table:

Table 1.33. Valid expressions

expression

type

semantics, pre/post-conditions

W::const_buffers_type

A type which meets the requirements of ConstBufferSequence. This is the type of buffer returned by W::get.

W{f,v,m}

The implementation calls this constructor to indicate that the fields being serialized form part of an HTTP request. The lifetime of f is guaranteed to end no earlier than after the W is destroyed.

W{f,v,c}

The implementation calls this constructor to indicate that the fields being serialized form part of an HTTP response. The lifetime of f is guaranteed to end no earlier than after the W is destroyed.

W{f}

The implementation calls this constructor to indicate that the fields being serialized form part of a chunked encoding final-chunk trailer. The lifetime of f is guaranteed to end no earlier than after the W is destroyed.

a.get()

W::const_buffers_type

Called once after construction, this function returns a constant buffer sequence containing the serialized representation of the HTTP request or response including the final carriage return linefeed sequence ("\r\n").

Copies may be made of the returned sequence, but the underlying memory is still owned by the writer. The implementation will destroy all copies of the buffer sequence before destroying a.


Exemplar
struct FieldsWriter
{
    // The type of buffers returned by `get`
    struct const_buffers_type;

    // Constructor for requests
    FieldsWriter(Fields const& f, unsigned version, verb method);

    // Constructor for responses
    FieldsWriter(Fields const& f, unsigned version, unsigned status);

    // Returns the serialized header buffers
    const_buffers_type
    get();
};
Models

PrevUpHomeNext