forked from boostorg/beast
message::prepare_payload replaces message::prepare (API Change):
Actions Required: * Change calls to msg.prepare to msg.prepare_payload. For messages with a user-defined Fields, provide the function prepare_payload_impl in the fields type according to the Fields requirements.
This commit is contained in:
1 parent
f9f6e1e0cc
commit
56a561da9a
20 files changed
+398
-114
No files matched your search
@@ -151,7 +151,7 @@ request.
|
||||
|
||||
Here we create an HTTP response indicating success. Note that this
|
||||
message has a body. The function
|
||||
[link beast.ref.beast__http__message.prepare prepare]
|
||||
[link beast.ref.beast__http__message.prepare_payload `message::prepare_payload`]
|
||||
automatically sets the Content-Length or Transfer-Encoding field
|
||||
depending on the content and type of the `body` member. The use
|
||||
of prepare is optional; these fields may also be set explicitly.
|
||||
|
||||
@@ -53,7 +53,7 @@ In this table:
|
||||
[
|
||||
If present, returns the serialized size of `v` not including
|
||||
any chunked transfer encoding. When this function is provided,
|
||||
[link beast.ref.beast__http__message.prepare `message::prepare`]
|
||||
[link beast.ref.beast__http__message.prepare_payload `message::prepare_payload`]
|
||||
will automatically set the content length field based on the
|
||||
value. Otherwise, the chunked transfer encoding will be set.
|
||||
]
|
||||
|
||||
@@ -25,6 +25,10 @@ In this table:
|
||||
|
||||
* `s` is a value of type [link beast.ref.beast__string_view `string_view`].
|
||||
|
||||
* `b` is a value of type `bool`
|
||||
|
||||
* `n` is a value of type `boost::optional<std::uint64_t>`.
|
||||
|
||||
[table Fields requirements
|
||||
[[expression][type][semantics, pre/post-conditions]]
|
||||
[
|
||||
@@ -88,6 +92,29 @@ In this table:
|
||||
This function may throw `std::invalid_argument` if the operation
|
||||
is not supported by the container.
|
||||
]
|
||||
][
|
||||
[`a.prepare_payload_impl(b,n)`]
|
||||
[]
|
||||
[
|
||||
Adjusts the Content-Length and Transfer-Encoding fields to
|
||||
account for the payload metadata indicated by `b` and `n` as
|
||||
follows:
|
||||
|
||||
* If `b` is `true`, the chunked Transfer-Encoding should be applied
|
||||
to the end of the list of encodings if it is not already there
|
||||
or if the field was not present. Any Content-Length fields should
|
||||
be removed.
|
||||
|
||||
* If `b` is `false` and `n` contains a value, set the Content-Length
|
||||
field to `*n`, replacing any previous Content-Length fields. Remove
|
||||
the chunked encoding from the end of the Transfer-Encoding field
|
||||
if the field is present ahd chunked is the last encoding.
|
||||
|
||||
* If `b` is `false` and `n` contains no value, remove all Content-Length
|
||||
fields, and remove the chunked encoding from the end of the
|
||||
Transfer-Encoding field if the field is present ahd chunked is the
|
||||
last encoding.
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
@@ -132,6 +159,14 @@ protected:
|
||||
@note Only called for responses.
|
||||
*/
|
||||
string_view get_reason_impl() const;
|
||||
|
||||
/** Updates the payload metadata.
|
||||
|
||||
@param b `true` if chunked
|
||||
|
||||
@param n The content length if known, otherwise `boost::none`
|
||||
*/
|
||||
void prepare_payload_impl(bool b, boost::optional<std::uint64_t> n)
|
||||
};
|
||||
```
|
||||
|
||||
|
||||
Reference in new issue
Block a user