diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fe50238..82f0822a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ Version 66: * string_param optimizations +* Add serializer request/response aliases -------------------------------------------------------------------------------- diff --git a/doc/5_04_serializer_streams.qbk b/doc/5_04_serializer_streams.qbk index 52664d2e..5a9c3431 100644 --- a/doc/5_04_serializer_streams.qbk +++ b/doc/5_04_serializer_streams.qbk @@ -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] diff --git a/doc/quickref.xml b/doc/quickref.xml index 5a8dbd0d..7047dc9a 100644 --- a/doc/quickref.xml +++ b/doc/quickref.xml @@ -42,8 +42,10 @@ no_chunk_decorator request request_parser + request_serializer response response_parser + response_serializer serializer string_body string_view_body diff --git a/example/doc/http_examples.hpp b/example/doc/http_examples.hpp index 1747e608..6ffe5e8f 100644 --- a/example/doc/http_examples.hpp +++ b/example/doc/http_examples.hpp @@ -65,7 +65,7 @@ send_expect_100_continue( req.set(field::expect, "100-continue"); // Create the serializer - serializer> sr{req}; + request_serializer> 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 sr{res}; + response_serializer sr{res}; // Send the header immediately. write_header(output, sr, ec); diff --git a/include/beast/http/serializer.hpp b/include/beast/http/serializer.hpp index 6e48d8bd..9a6faacd 100644 --- a/include/beast/http/serializer.hpp +++ b/include/beast/http/serializer.hpp @@ -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; + +/// A serializer for HTTP/1 responses +template< + class Body, + class Fields = fields, + class ChunkDecorator = no_chunk_decorator> +using response_serializer = serializer; + } // http } // beast diff --git a/test/http/doc_snippets.cpp b/test/http/doc_snippets.cpp index f2ac74be..acd2d6ac 100644 --- a/test/http/doc_snippets.cpp +++ b/test/http/doc_snippets.cpp @@ -123,7 +123,7 @@ void fxx() { //[http_snippet_10 response res; - serializer sr{res}; + response_serializer 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; + +/// A serializer for HTTP/1 responses +template< + class Body, + class Fields = fields, + class ChunkDecorator = no_chunk_decorator> +using response_serializer = serializer; + //] #endif diff --git a/test/http/write.cpp b/test/http/write.cpp index 9df14ae8..8c6f790a 100644 --- a/test/http/write.cpp +++ b/test/http/write.cpp @@ -773,7 +773,7 @@ public: { auto m = m0; error_code ec; - serializer sr{m}; + response_serializer sr{m}; sr.split(true); for(;;) { @@ -787,7 +787,7 @@ public: { auto m = m0; error_code ec; - serializer sr{m}; + response_serializer 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 sr{m}; + response_serializer sr{m}; sr.split(true); for(;;) { @@ -851,7 +851,7 @@ public: { auto m = m0; error_code ec; - serializer sr{m}; + response_serializer sr{m}; sr.split(true); for(;;) {