Refine Body::size specification

This commit is contained in:
Vinnie Falco
2017-07-02 14:24:36 -07:00
parent a2ca4e41ca
commit ff33783d11
3 changed files with 31 additions and 5 deletions

View File

@@ -3,6 +3,7 @@ Version 72:
HTTP: HTTP:
* Tidy up set payload in http-server-fast * Tidy up set payload in http-server-fast
* Refine Body::size specification
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View File

@@ -48,14 +48,37 @@ In this table:
the message body for serialization. the message body for serialization.
] ]
][ ][
[`X::size(X::value_type const& v)`] [`X::size(X::value_type v)`]
[`std::uint64_t`] [`std::uint64_t`]
[ [
If present, returns the serialized size of `v` not including This static member function is optional. It returns the payload
any chunked transfer encoding. When this function is provided, size of `v` not including any chunked transfer encoding. The
function shall not exit via an exception.
When this function is present:
* The function shall not fail
* A call to
[link beast.ref.beast__http__message.payload_size `message::payload_size`]
will return the same value as `size`.
* A call to
[link beast.ref.beast__http__message.prepare_payload `message::prepare_payload`] [link beast.ref.beast__http__message.prepare_payload `message::prepare_payload`]
will automatically set the content length field based on the will remove "chunked" from the Transfer-Encoding field if it appears
value. Otherwise, the chunked transfer encoding will be set. as the last encoding, and will set the Content-Length field to the
returned value.
Otherwise, when the function is omitted:
* A call to
[link beast.ref.beast__http__message.payload_size `message::payload_size`]
will return `boost::none`.
* A call to
[link beast.ref.beast__http__message.prepare_payload `message::prepare_payload`]
will erase the Content-Length field, and add "chunked" as the last
encoding in the Transfer-Encoding field if it is not already present.
] ]
][ ][
[`is_body<X>`] [`is_body<X>`]

View File

@@ -134,6 +134,8 @@ struct BodyWriter
{ {
// The specification requires this to indicate "no error" // The specification requires this to indicate "no error"
ec = {}; ec = {};
return boost::asio::buffer_size(buffers);
} }
/** Called when the body is complete. /** Called when the body is complete.