@@ -33,6 +33,7 @@ namespace boost {
3333namespace http_proto {
3434
3535#ifndef BOOST_HTTP_PROTO_DOCS
36+ class serializer_service ;
3637class message_view_base ;
3738#endif
3839
@@ -66,6 +67,73 @@ class serializer
6667 using const_buffers_type =
6768 buffers::const_buffer_span;
6869
70+ /* * Serializer configuration settings.
71+ */
72+ struct config
73+ {
74+ /* * True if serializer can encode deflate Content-Encoding.
75+
76+ The @ref zlib::deflate_service must already be
77+ installed thusly, or else an exception
78+ is thrown.
79+ */
80+ bool apply_deflate_encoder = false ;
81+
82+ /* * True if serializer can encode gzip Content-Encoding.
83+
84+ The @ref zlib::deflate_service must already be
85+ installed thusly, or else an exception
86+ is thrown.
87+ */
88+ bool apply_gzip_encoder = false ;
89+
90+ /* * Specifies the zlib compression level 0..9.
91+
92+ A compression level of 1 provides the fastest speed,
93+ while level 9 offers the best compression. Level 0
94+ applies no compression at all.
95+ */
96+ int zlib_comp_level = 6 ;
97+
98+ /* * Specifies the zlib windows bits 9..15.
99+
100+ The windows bits controls the size of the history
101+ buffer used when compressing data. Larger values
102+ produce better compression at the expense of
103+ greater memory usage.
104+ */
105+ int zlib_window_bits = 15 ;
106+
107+ /* * Specifies the zlib memory level 1..9.
108+
109+ The memory level controls the amount of memory
110+ used for the internal compression state. Larger
111+ values use more memory, but are faster and
112+ produce smaller output.
113+ */
114+ int zlib_mem_level = 8 ;
115+
116+ /* * Minimum space for payload buffering.
117+
118+ This cannot be zero.
119+ */
120+ std::size_t payload_buffer = 8192 ;
121+
122+ /* * Space to reserve for type-erasure.
123+
124+ This space is used for the following
125+ purposes:
126+
127+ @li Storing an instance of the user-provided
128+ @ref source objects.
129+
130+ @li Storing an instance of the user-provided
131+ ConstBufferSequence.
132+
133+ */
134+ std::size_t max_type_erase = 1024 ;
135+ };
136+
69137 struct stream ;
70138
71139 /* * Destructor
@@ -82,19 +150,12 @@ class serializer
82150 /* * Constructor
83151
84152 @param ctx The serializer will access services
85- registered with this context.
153+ registered with this context.
86154 */
87155 BOOST_HTTP_PROTO_DECL
88156 serializer (
89157 context& ctx);
90158
91- /* * Constructor
92- */
93- BOOST_HTTP_PROTO_DECL
94- serializer (
95- context& ctx,
96- std::size_t buffer_size);
97-
98159 // --------------------------------------------
99160
100161 /* * Prepare the serializer for a new stream
@@ -216,6 +277,7 @@ class serializer
216277 consume (std::size_t n);
217278
218279private:
280+ friend class serializer_service ;
219281 class filter ;
220282 class const_buf_gen_base ;
221283 template <class >
@@ -282,6 +344,8 @@ class serializer
282344 };
283345
284346 context& ctx_;
347+ serializer_service& svc_;
348+
285349 detail::workspace ws_;
286350
287351 const_buf_gen_base* buf_gen_;
@@ -304,6 +368,16 @@ class serializer
304368
305369// ------------------------------------------------
306370
371+ /* * Install the serializer service.
372+ */
373+ BOOST_HTTP_PROTO_DECL
374+ void
375+ install_serializer_service (
376+ context& ctx,
377+ serializer::config const & cfg);
378+
379+ // ------------------------------------------------
380+
307381/* * The type used for caller-provided body data during
308382 serialization.
309383
0 commit comments