forked from boostorg/beast
98 lines
2.6 KiB
Plaintext
98 lines
2.6 KiB
Plaintext
[/
|
|
Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
|
|
|
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
]
|
|
|
|
[section:FieldsReader FieldsReader]
|
|
|
|
A [*FieldsReader] 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.
|
|
|
|
In this table:
|
|
|
|
* `X` denotes a type that meets the requirements of [*FieldsReader].
|
|
|
|
* `F` denotes a __Fields__ where
|
|
`std::is_same<X, F::reader>::value == `true`.
|
|
|
|
* `a` is a value of type `X`.
|
|
|
|
* `f` is a value of type `F`.
|
|
|
|
* `v` is an `unsigned` value representing the HTTP version.
|
|
|
|
* `c` is an `unsigned` representing the HTTP status-code.
|
|
|
|
* `m` is a value of type [link beast.ref.beast__http__verb `verb`].
|
|
|
|
[table FieldsReader requirements
|
|
[[expression][type][semantics, pre/post-conditions]]
|
|
[
|
|
[`X::const_buffers_type`]
|
|
[]
|
|
[
|
|
A type which meets the requirements of __ConstBufferSequence__.
|
|
This is the type of buffer returned by `X::get`.
|
|
]
|
|
][
|
|
[`X(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 `X` is destroyed.
|
|
]
|
|
][
|
|
[`X(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 `X` is destroyed.
|
|
]
|
|
][
|
|
[`a.get()`]
|
|
[X::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"`).
|
|
]
|
|
][
|
|
[`is_fields_reader<F>`]
|
|
[`std::true_type`]
|
|
[
|
|
An alias for `std::true_type` for `F`, otherwise an alias
|
|
for `std::false_type`.
|
|
]
|
|
]
|
|
]
|
|
|
|
Exemplar:
|
|
```
|
|
struct FieldsReader
|
|
{
|
|
// The type of buffers returned by `get`
|
|
using const_buffers_type = implementation-defined;
|
|
|
|
// Constructor for requests
|
|
FieldsReader(F const& f, unsigned version, verb method);
|
|
|
|
// Constructor for responses
|
|
FieldsReader(F const& f, unsigned version, unsigned status);
|
|
|
|
// Returns the serialized header buffers
|
|
const_buffers_type
|
|
get();
|
|
};
|
|
```
|
|
|
|
[endsect]
|