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 a snapshot of the develop branch, built from commit f41a42f804.
PrevUpHomeNext
http::parser::value_type

The type of message returned by the parser.

Synopsis
using value_type = message< isRequest, Body, basic_fields< Allocator > >;
Types

Name

Description

body_type

The type providing the body traits.

fields_type

The type representing the fields.

header_type

The base class used to hold the header portion of the message.

is_request

Indicates if the header is a request or response.

Member Functions

Name

Description

base

Returns the header portion of the message.

body

Returns the body.

chunked

Returns true if the chunked Transfer-Encoding is specified.

Set or clear the chunked Transfer-Encoding.

content_length

Set or clear the Content-Length field.

has_content_length

Returns true if the Content-Length field is present.

keep_alive

Returns true if the message semantics indicate keep-alive.

Set the keep-alive message semantic option.

message

Constructor.

Construct a message.

method

Return the request-method verb.

Set the request-method.

method_string

Return the request-method as a string.

Set the request-method.

need_eof

Returns true if the message semantics require an end of file.

operator=

Assignment.

payload_size

Returns the payload size of the body in octets if possible.

prepare_payload

Prepare the message payload fields for the body.

reason

Return the response reason-phrase.

Set the response reason-phrase (deprecated)

result

The response status-code result.

Set the response status-code.

Set the response status-code as an integer.

result_int

The response status-code expressed as an integer.

target

Returns the request-target string.

Set the request-target string.

version

Return the HTTP-version.

Set the HTTP-version.

This container is derived from the Fields template type. To understand all of the members of this class it is necessary to view the declaration for the Fields type. When using the default fields container, those declarations are in fields. A message can be a request or response, depending on the isRequest template argument value. Requests and responses have different types; functions may be overloaded based on the type if desired. The Body template argument type determines the model used to read or write the content body of the message. Newly constructed messages objects have version set to HTTP/1.1. Newly constructed response objects also have result code set to status::ok.

Template Parameters

Type

Description

isRequest

true if this represents a request, or false if this represents a response. Some class data members are conditionally present depending on this value.

Body

A type meeting the requirements of Body.

Fields

The type of container used to hold the field value pairs.

Types

Name

Description

allocator_type

The type of allocator used.

const_iterator

A constant iterator to the field sequence.

iterator

A constant iterator to the field sequence.

key_compare

A strictly less predicate for comparing keys, using a case-insensitive comparison.

value_type

The type of element used to represent a field.

writer

The algorithm used to serialize the header.

Member Functions

Name

Description

at

Returns the value for a field, or throws an exception.

basic_fields

Constructor.

Move constructor.

Copy constructor.

begin

Return a const iterator to the beginning of the field sequence.

cbegin

Return a const iterator to the beginning of the field sequence.

cend

Return a const iterator to the end of the field sequence.

clear

Remove all fields from the container.

count

Return the number of fields with the specified name.

end

Return a const iterator to the end of the field sequence.

equal_range

Returns a range of iterators to the fields with the specified name.

erase

Remove a field.

Remove all fields with the specified name.

find

Returns an iterator to the case-insensitive matching field.

Returns an iterator to the case-insensitive matching field name.

get_allocator

Return a copy of the allocator associated with the container.

insert

Insert a field.

key_comp

Returns a copy of the key comparison function.

operator=

Move assignment.

Copy assignment.

operator[]

Returns the value for a field, or "" if it does not exist.

Returns the value for a case-insensitive matching header, or "" if it does not exist.

set

Set a field value, removing any other instances of that field.

swap

Return a buffer sequence representing the trailers.

~basic_fields [destructor]

Destructor.

Protected Member Functions

Name

Description

get_chunked_impl

Returns the chunked Transfer-Encoding setting.

get_keep_alive_impl

Returns the keep-alive setting.

get_method_impl

Returns the request-method string.

get_reason_impl

Returns the response reason-phrase string.

get_target_impl

Returns the request-target string.

has_content_length_impl

Returns true if the Content-Length field is present.

set_chunked_impl

Adjusts the chunked Transfer-Encoding value.

set_content_length_impl

Sets or clears the Content-Length field.

set_keep_alive_impl

Adjusts the Connection field.

set_method_impl

Set or clear the method string.

set_reason_impl

Set or clear the reason string.

set_target_impl

Set or clear the target string.

Friends

Name

Description

swap

Swap two field containers.

This container is designed to store the field value pairs that make up the fields and trailers in an HTTP message. Objects of this type are iterable, with each element holding the field name and field value. Field names are stored as-is, but comparisons are case-insensitive. The container behaves as a std::multiset; there will be a separate value for each occurrence of the same field name. When the container is iterated the fields are presented in the order of insertion, with fields having the same name following each other consecutively. Meets the requirements of Fields

Template Parameters

Type

Description

Allocator

The allocator to use.

Description

PrevUpHomeNext