Body documentation work

This commit is contained in:
Vinnie Falco
2017-06-07 04:36:45 -07:00
parent 943830f6ed
commit 80ca9a5961
4 changed files with 53 additions and 54 deletions

View File

@@ -8,6 +8,7 @@ Version 50
* Use field in basic_parser * Use field in basic_parser
* Tidy up basic_fields, header, and field concepts * Tidy up basic_fields, header, and field concepts
* Fields concept work * Fields concept work
* Body documentation work
API Changes: API Changes:

View File

@@ -15,6 +15,9 @@ In this table:
* `X` is a type meeting the requirements of [*Body]. * `X` is a type meeting the requirements of [*Body].
* `m` is a value of type `message<b, X, F>` where `b` is a `bool` value
and `F` is a type meeting the requirements of [*Fields].
[table Body requirements [table Body requirements
[[expression] [type] [semantics, pre/post-conditions]] [[expression] [type] [semantics, pre/post-conditions]]
[ [
@@ -25,8 +28,7 @@ In this table:
If this is not movable or not copyable, the containing message If this is not movable or not copyable, the containing message
will be not movable or not copyable. will be not movable or not copyable.
] ]
] ][
[
[`X::writer`] [`X::writer`]
[] []
[ [
@@ -36,8 +38,7 @@ In this table:
this type to obtain buffers into which parsed body octets this type to obtain buffers into which parsed body octets
are placed. are placed.
] ]
] ][
[
[`X::reader`] [`X::reader`]
[] []
[ [
@@ -46,8 +47,17 @@ In this table:
constructs an object of this type to obtain buffers representing constructs an object of this type to obtain buffers representing
the message body for serialization. the message body for serialization.
] ]
] ][
[ [`X::size(m)`]
[`std::uint64_t`]
[
If present, returns the serialized size of `m.body` not including
any chunked transfer encoding. When this function is provided,
[link beast.ref.http__message.prepare `message::prepare`]
will automatically set the content length field based on the
value. Otherwise, the chunked transfer encoding will be set.
]
][
[`is_body<X>`] [`is_body<X>`]
[`std::true_type`] [`std::true_type`]
[ [
@@ -57,4 +67,24 @@ In this table:
] ]
] ]
Exemplar:
```
struct body
{
using value_type = implementation_defined;
/// The algorithm used for extracting buffers
class reader;
/// The algorithm used for inserting buffers
class writer;
/// Returns the body's payload size
template<bool isRequest, class Fields>
static
std::uint64_t
size(message<isRequest, empty_body, Fields> const& m);
}
```
[endsect] [endsect]

View File

@@ -45,8 +45,7 @@ In this table:
A type which meets the requirements of __ConstBufferSequence__. A type which meets the requirements of __ConstBufferSequence__.
This is the type of buffer returned by `X::get`. This is the type of buffer returned by `X::get`.
] ]
] ][
[
[`X::is_deferred`] [`X::is_deferred`]
[] []
[ [
@@ -62,16 +61,14 @@ In this table:
latency experienced by the remote host when expecting to read latency experienced by the remote host when expecting to read
the HTTP header. the HTTP header.
] ]
] ][
[
[`X(m);`] [`X(m);`]
[] []
[ [
Constructible from `m`. The lifetime of `m` is guaranteed Constructible from `m`. The lifetime of `m` is guaranteed
to end no earlier than after the `X` is destroyed. to end no earlier than after the `X` is destroyed.
] ]
] ][
[
[`a.init(ec)`] [`a.init(ec)`]
[] []
[ [
@@ -79,23 +76,7 @@ In this table:
error code in `ec`, the serialization is aborted and the error error code in `ec`, the serialization is aborted and the error
is propagated to the caller. is propagated to the caller.
] ]
] ][
[
[`a.content_length()`]
[`std::uint64_t`]
[
If this member is present, it is called after initialization
and before calls to provide buffers. The serialized message will
have the Content-Length field set to the value returned from
this function. If this member is absent, the serialized message
body will be chunk-encoded for HTTP versions 1.1 and later, else
the serialized message body will be sent unmodified, with the
error `boost::asio::error::eof` returned to the caller, to notify
they should close the connection to indicate the end of the message.
This function must be `noexcept`.
]
]
[
[`a.get(ec)`] [`a.get(ec)`]
[`R<X::const_buffers_type>`] [`R<X::const_buffers_type>`]
[ [
@@ -110,8 +91,7 @@ In this table:
or `false` if the buffer returned on this call is the last or `false` if the buffer returned on this call is the last
buffer representing the body. buffer representing the body.
] ]
] ][
[
[`is_body_reader<B>`] [`is_body_reader<B>`]
[`std::true_type`] [`std::true_type`]
[ [
@@ -122,9 +102,9 @@ In this table:
] ]
[note [note
Definitions for required [*BodyReader] member functions should Definitions for required [*BodyReader] member functions may
be declared inline so the generated code can become part of the be declared inline so the generated code can become part of
implementation. the implementation.
] ]
Exemplar: Exemplar:
@@ -160,16 +140,6 @@ public:
void void
init(error_code& ec); init(error_code& ec);
/** Returns the content length.
If this member is present, the implementation will set the
Content-Length field accordingly. If absent, the implementation
will use chunk-encoding or terminate the connection to indicate
the end of the message.
*/
std::uint64_t
content_length();
/** Returns the next buffer in the body. /** Returns the next buffer in the body.
@li If the return value is `boost::none` (unseated optional) and @li If the return value is `boost::none` (unseated optional) and

View File

@@ -49,8 +49,7 @@ In the table below:
will be called the complete header is stored in `m`, and before will be called the complete header is stored in `m`, and before
parsing body octets for messages indicating that a body is present. parsing body octets for messages indicating that a body is present.
] ]
] ][
[
[`a.init(length,ec)`] [`a.init(length,ec)`]
[] []
[ [
@@ -61,8 +60,7 @@ In the table below:
[*BodyWriter] may use this information to optimize allocation. [*BodyWriter] may use this information to optimize allocation.
If `ec` is set, the error will be propagated to the caller. If `ec` is set, the error will be propagated to the caller.
] ]
] ][
[
[`a.put(b,ec)`] [`a.put(b,ec)`]
[] []
[ [
@@ -70,16 +68,14 @@ In the table below:
into the body representation. into the body representation.
If `ec` is set, the error will be propagated to the caller. If `ec` is set, the error will be propagated to the caller.
] ]
] ][
[
[`a.finish(ec)`] [`a.finish(ec)`]
[] []
[ [
This function is called when no more body octets are remaining. This function is called when no more body octets are remaining.
If `ec` is set, the error will be propagated to the caller. If `ec` is set, the error will be propagated to the caller.
] ]
] ][
[
[`is_body_writer<B>`] [`is_body_writer<B>`]
[`std::true_type`] [`std::true_type`]
[ [
@@ -88,9 +84,11 @@ In the table below:
] ]
] ]
] ]
[note [note
Definitions for required [*BodyWriter] member functions should be declared Definitions for required [*BodyReader] member functions may
inline so the generated code can become part of the implementation. be declared inline so the generated code can become part of
the implementation.
] ]
Exemplar: Exemplar: