...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Warning | |
---|---|
The Fields concept is deprecated and will be removed in a future version. The information on this page is provided for historical purposes only. |
An instance of Fields is a container for holding HTTP header fields and their values. The implementation also calls upon the container to store the request target and non-standard strings for method and obsolete reason phrase as needed. Types which meet these requirements can always be serialized.
In this table:
F
denotes a type that
meets the requirements of Fields.
W
denotes a type meeting
the requirements of FieldsWriter.
a
denotes a value of
type F
.
c
denotes a (possibly
const) value of type F
.
b
is a value of type
bool
n
is a value of type
boost::optional<std::uint64_t>
.
s
is a value of type
string_view
.
v
is a value of type
unsigned int
representing the HTTP-version.
Table 1.40. Valid expressions
Expression |
Type |
Semantics, Pre/Post-conditions |
---|---|---|
|
|
A type which meets the requirements of FieldsWriter. |
|
|
Returns the method text. The implementation only calls this function
for request headers when retrieving the method text previously
set with a call to |
|
|
Returns the target string. The implementation only calls this function for request headers. |
|
|
Returns the obsolete request text. The implementation only calls
this for response headers when retrieving the reason text previously
set with a call to |
|
|
Returns
|
|
|
Returns
|
|
|
Returns |
|
Stores a copy of |
|
|
Stores a copy of |
|
|
Stores a copy of |
|
|
Adjusts the Transfer-Encoding field value as follows:
If the result of adjusting the field value produces an empty string, the field is removed from the container. |
|
|
Adjusts the Content-Length field value as follows:
|
|
|
Adjusts the Connection field value depending
on the values of
If the result of adjusting the field value produces an empty string, the field is removed from the container. |
class Fields { public: /// Constructed as needed when fields are serialized struct writer; protected: /** Returns the request-method string. @note Only called for requests. */ string_view get_method_impl() const; /** Returns the request-target string. @note Only called for requests. */ string_view get_target_impl() const; /** Returns the response reason-phrase string. @note Only called for responses. */ string_view get_reason_impl() const; /** Returns the chunked Transfer-Encoding setting */ bool get_chunked_impl() const; /** Returns the keep-alive setting */ bool get_keep_alive_impl(unsigned version) const; /** Returns `true` if the Content-Length field is present. */ bool has_content_length_impl() const; /** Set or clear the method string. @note Only called for requests. */ void set_method_impl(string_view s); /** Set or clear the target string. @note Only called for requests. */ void set_target_impl(string_view s); /** Set or clear the reason string. @note Only called for responses. */ void set_reason_impl(string_view s); /** Sets or clears the chunked Transfer-Encoding value */ void set_chunked_impl(bool value); /** Sets or clears the Content-Length field */ void set_content_length_impl(boost::optional<std::uint64_t>); /** Adjusts the Connection field */ void set_keep_alive_impl(unsigned version, bool keep_alive); }; static_assert(is_fields<Fields>::value, "Fields type requirements not met");