boost::http::fields

A modifiable container of HTTP fields.

Synopsis

Declared in <boost/http/fields.hpp>

class fields final
    : public fields_base

Description

This container owns a collection of HTTP fields, represented by a buffer which is managed by performing dynamic memory allocations as needed. The contents may be inspected and modified, and the implementation maintains a useful invariant: changes to the fields always leave it in a valid state.

Example

fields fs;

fs.set(field::host, "example.com");
fs.set(field::accept_encoding, "gzip, deflate, br");
fs.set(field::cache_control, "no-cache");

assert(fs.buffer() ==
    "Host: example.com\r\n"
    "Accept-Encoding: gzip, deflate, br\r\n"
    "Cache-Control: no-cache\r\n"
    "\r\n");

Base Classes

Name Description

fields_base

Mixin for modifiable HTTP fields.

Types

Name

Description

iterator

A bidirectional iterator to HTTP fields.

reference

A view to an HTTP field.

reverse_iterator

A bidirectional reverse iterator to HTTP fields.

subrange

A forward range of matching fields.

value_type

A value type which represent an HTTP field.

const_iterator

A bidirectional iterator to HTTP fields.

const_reference

A view to an HTTP field.

const_reverse_iterator

A bidirectional iterator to HTTP fields.

Member Functions

Name

Description

fields [constructor]

Constructor.

operator=

Assignment.

append

Append a header.

at

Return the value of a field, or throws an exception.

begin

Return an iterator to the beginning.

buffer

Return a string view representing the serialized data.

capacity_in_bytes

Return the total number of bytes allocated by the container.

clear

Clear contents while preserving the capacity.

count

Return the number of matching fields.

end

Return an iterator to the end.

erase

erase overloads

exists

Return true if a field exists.

find

Return an iterator to the matching element if it exists.

find_all

Return a forward range containing values for all matching fields.

find_last

Return an iterator to the matching element if it exists.

insert

Insert a header.

max_capacity_in_bytes

Return the maximum allowed capacity in bytes.

rbegin

Return a reverse iterator to the beginning.

rend

Return a reverse iterator to the end.

reserve_bytes

Adjust the capacity without changing the size.

set

Set a header value.

set_max_capacity_in_bytes

Set the maximum allowed capacity in bytes.

shrink_to_fit

Remove excess capacity.

size

Return the number of fields in the container.

swap

Swap.

value_or

Return the value of a field or a default if missing.

Static Member Functions

Name

Description

max_size

Return the largest possible serialized message.

Friends

Name Description

boost::http::swap

Swap.

See Also

Created with MrDocs