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