mirror of
https://github.com/boostorg/beast.git
synced 2025-07-31 05:17:26 +02:00
Update stream write documentation for end of stream changes
This commit is contained in:
@ -2,6 +2,7 @@ Version 126:
|
|||||||
|
|
||||||
* Add CppCon2017 presentation link
|
* Add CppCon2017 presentation link
|
||||||
* Update README.md
|
* Update README.md
|
||||||
|
* Update stream write documentation for end of stream changes
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -94,14 +94,7 @@ overflow attacks. The following code will print the error message:
|
|||||||
[heading Writing]
|
[heading Writing]
|
||||||
|
|
||||||
A set of free functions allow serialization of an entire HTTP message to
|
A set of free functions allow serialization of an entire HTTP message to
|
||||||
a stream. If a response has no declared content length and no chunked
|
a stream. This example constructs and sends an HTTP response:
|
||||||
transfer encoding, then the end of the message is indicated by the server
|
|
||||||
closing the connection. When sending such a response, Beast will return the
|
|
||||||
[link beast.ref.boost__beast__http__error `error::end_of_stream`]
|
|
||||||
from the write algorithm to indicate
|
|
||||||
to the caller that the connection should be closed. This example
|
|
||||||
constructs and sends a response whose body length is determined by
|
|
||||||
the number of octets received prior to the server closing the connection:
|
|
||||||
|
|
||||||
[http_snippet_7]
|
[http_snippet_7]
|
||||||
|
|
||||||
|
@ -116,11 +116,10 @@ void fxx() {
|
|||||||
res.result(status::ok);
|
res.result(status::ok);
|
||||||
res.set(field::server, "Beast");
|
res.set(field::server, "Beast");
|
||||||
res.body() = "Hello, world!";
|
res.body() = "Hello, world!";
|
||||||
|
res.prepare_payload();
|
||||||
|
|
||||||
error_code ec;
|
error_code ec;
|
||||||
write(sock, res, ec);
|
write(sock, res, ec);
|
||||||
if(ec == error::end_of_stream)
|
|
||||||
sock.close();
|
|
||||||
//]
|
//]
|
||||||
|
|
||||||
//[http_snippet_8
|
//[http_snippet_8
|
||||||
|
Reference in New Issue
Block a user