Add header aliases

This commit is contained in:
Vinnie Falco
2017-06-23 06:44:36 -07:00
parent c2d3532da2
commit 9f7f36a3e9
4 changed files with 30 additions and 3 deletions

View File

@ -7,6 +7,7 @@ Version 66:
* Fix unused parameter warning
* Handle bad_alloc in parser
* Tidy up message piecewise ctors
* Add header aliases
--------------------------------------------------------------------------------

View File

@ -7,8 +7,8 @@
[section Message Containers]
Beast provides a single class template __message__ which models
HTTP/1 and
Beast provides a single class template __message__ and some aliases which
model HTTP/1 and
[@https://tools.ietf.org/html/rfc7540 HTTP/2]
messages:
```
@ -18,6 +18,14 @@ template<
class Body, // Controls the container and algorithms used for the body
class Fields = fields> // The type of container to store the fields
class message;
/// A typical HTTP request
template<class Body, class Fields = fields>
using request = message<true, Body, Fields>;
/// A typical HTTP response
template<class Body, class Fields = fields>
using response = message<false, Body, Fields>;
```
The container offers value semantics including move and copy if supported
@ -33,13 +41,21 @@ the container. The library comes with a collection of common body types.
As with fields, user defined body types are possible.
Sometimes it is desired to only work with a header. Beast provides a single
class template __header__ to model HTTP/1 and HTTP/2 headers:
class template __header__ and some aliases to model HTTP/1 and HTTP/2 headers:
```
/// An HTTP header
template<
bool isRequest, // `true` for requests, `false` for responses
class Fields = fields> // The type of container to store the fields
class header;
/// A typical HTTP request header
template<class Fields>
using request_header = header<true, Fields>;
/// A typical HTTP response header
template<class Fields>
using response_header = header<false, Fields>;
```
Requests and responses share the version, fields, and body but have

View File

@ -41,9 +41,11 @@
<member><link linkend="beast.ref.beast__http__parser">parser</link></member>
<member><link linkend="beast.ref.beast__http__no_chunk_decorator">no_chunk_decorator</link></member>
<member><link linkend="beast.ref.beast__http__request">request</link></member>
<member><link linkend="beast.ref.beast__http__request_header">request_header</link></member>
<member><link linkend="beast.ref.beast__http__request_parser">request_parser</link></member>
<member><link linkend="beast.ref.beast__http__request_serializer">request_serializer</link></member>
<member><link linkend="beast.ref.beast__http__response">response</link></member>
<member><link linkend="beast.ref.beast__http__response_header">response_header</link></member>
<member><link linkend="beast.ref.beast__http__response_parser">response_parser</link></member>
<member><link linkend="beast.ref.beast__http__response_serializer">response_serializer</link></member>
<member><link linkend="beast.ref.beast__http__serializer">serializer</link></member>

View File

@ -347,6 +347,14 @@ private:
#endif
};
/// A typical HTTP request header
template<class Fields = fields>
using request_header = header<true, Fields>;
/// A typical HTTP response header
template<class Fields = fields>
using response_header = header<false, Fields>;
/** A container for a complete HTTP message.
This container is derived from the `Fields` template type.