mirror of
https://github.com/boostorg/beast.git
synced 2025-08-01 22:04:34 +02:00
Add serializer request/response aliases
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
Version 66:
|
||||
|
||||
* string_param optimizations
|
||||
* Add serializer request/response aliases
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
@@ -20,7 +20,7 @@ at once, such as:
|
||||
|
||||
These tasks may be performed by using the serializer stream interfaces.
|
||||
To use these interfaces, first construct a __serializer__ object with
|
||||
the message to be sent. The serializer type has this declaration:
|
||||
the message to be sent. The serializer type has these declarations:
|
||||
|
||||
[http_snippet_9]
|
||||
|
||||
|
@@ -42,8 +42,10 @@
|
||||
<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_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_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>
|
||||
<member><link linkend="beast.ref.beast__http__string_body">string_body</link></member>
|
||||
<member><link linkend="beast.ref.beast__http__string_view_body">string_view_body</link></member>
|
||||
|
@@ -65,7 +65,7 @@ send_expect_100_continue(
|
||||
req.set(field::expect, "100-continue");
|
||||
|
||||
// Create the serializer
|
||||
serializer<true, Body, basic_fields<Allocator>> sr{req};
|
||||
request_serializer<Body, basic_fields<Allocator>> sr{req};
|
||||
|
||||
// Send just the header
|
||||
write_header(stream, sr, ec);
|
||||
@@ -214,7 +214,7 @@ send_cgi_response(
|
||||
// to acquire buffers from the body (which would return
|
||||
// the error http::need_buffer because we set `data`
|
||||
// to `nullptr` above).
|
||||
serializer<false, buffer_body, fields> sr{res};
|
||||
response_serializer<buffer_body, fields> sr{res};
|
||||
|
||||
// Send the header immediately.
|
||||
write_header(output, sr, ec);
|
||||
|
@@ -320,6 +320,20 @@ public:
|
||||
consume(std::size_t n);
|
||||
};
|
||||
|
||||
/// A serializer for HTTP/1 requests
|
||||
template<
|
||||
class Body,
|
||||
class Fields = fields,
|
||||
class ChunkDecorator = no_chunk_decorator>
|
||||
using request_serializer = serializer<true, Body, Fields, ChunkDecorator>;
|
||||
|
||||
/// A serializer for HTTP/1 responses
|
||||
template<
|
||||
class Body,
|
||||
class Fields = fields,
|
||||
class ChunkDecorator = no_chunk_decorator>
|
||||
using response_serializer = serializer<false, Body, Fields, ChunkDecorator>;
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
|
||||
|
@@ -123,7 +123,7 @@ void fxx() {
|
||||
//[http_snippet_10
|
||||
|
||||
response<string_body> res;
|
||||
serializer<false, string_body, fields> sr{res};
|
||||
response_serializer<string_body, fields> sr{res};
|
||||
|
||||
//]
|
||||
}
|
||||
@@ -331,14 +331,29 @@ namespace http {
|
||||
#if 0
|
||||
//[http_snippet_9]
|
||||
|
||||
/// Provides buffer oriented HTTP message serialization functionality.
|
||||
template<
|
||||
bool isRequest,
|
||||
class Body,
|
||||
class Fields,
|
||||
class Fields = fields,
|
||||
class ChunkDecorator = no_chunk_decorator
|
||||
>
|
||||
class serializer;
|
||||
|
||||
/// A serializer for HTTP/1 requests
|
||||
template<
|
||||
class Body,
|
||||
class Fields = fields,
|
||||
class ChunkDecorator = no_chunk_decorator>
|
||||
using request_serializer = serializer<true, Body, Fields, ChunkDecorator>;
|
||||
|
||||
/// A serializer for HTTP/1 responses
|
||||
template<
|
||||
class Body,
|
||||
class Fields = fields,
|
||||
class ChunkDecorator = no_chunk_decorator>
|
||||
using response_serializer = serializer<false, Body, Fields, ChunkDecorator>;
|
||||
|
||||
//]
|
||||
#endif
|
||||
|
||||
|
@@ -773,7 +773,7 @@ public:
|
||||
{
|
||||
auto m = m0;
|
||||
error_code ec;
|
||||
serializer<false, Body, fields> sr{m};
|
||||
response_serializer<Body, fields> sr{m};
|
||||
sr.split(true);
|
||||
for(;;)
|
||||
{
|
||||
@@ -787,7 +787,7 @@ public:
|
||||
{
|
||||
auto m = m0;
|
||||
error_code ec;
|
||||
serializer<false, Body, fields> sr{m};
|
||||
response_serializer<Body, fields> sr{m};
|
||||
sr.split(true);
|
||||
for(;;)
|
||||
{
|
||||
@@ -837,7 +837,7 @@ public:
|
||||
auto m = m0;
|
||||
error_code ec;
|
||||
test::string_ostream so{get_io_service(), 3};
|
||||
serializer<false, Body, fields> sr{m};
|
||||
response_serializer<Body, fields> sr{m};
|
||||
sr.split(true);
|
||||
for(;;)
|
||||
{
|
||||
@@ -851,7 +851,7 @@ public:
|
||||
{
|
||||
auto m = m0;
|
||||
error_code ec;
|
||||
serializer<false, Body, fields> sr{m};
|
||||
response_serializer<Body, fields> sr{m};
|
||||
sr.split(true);
|
||||
for(;;)
|
||||
{
|
||||
|
Reference in New Issue
Block a user