@@ -113,13 +113,13 @@ class zlib_filter
113113
114114public:
115115 zlib_filter (
116- rts::context& ctx,
116+ const rts::context* ctx,
117117 http_proto::detail::workspace& ws,
118118 int comp_level,
119119 int window_bits,
120120 int mem_level)
121121 : zlib_filter_base(ws)
122- , svc_(ctx. get_service<rts::zlib::deflate_service>())
122+ , svc_(ctx-> get_service<rts::zlib::deflate_service>())
123123 {
124124 system::error_code ec = static_cast <rts::zlib::error>(svc_.init2 (
125125 strm_,
@@ -179,11 +179,11 @@ class brotli_filter
179179
180180public:
181181 brotli_filter (
182- rts::context& ctx,
182+ const rts::context* ctx,
183183 http_proto::detail::workspace&,
184184 std::uint32_t comp_quality,
185185 std::uint32_t comp_window)
186- : svc_(ctx. get_service<rts::brotli::encode_service>())
186+ : svc_(ctx-> get_service<rts::brotli::encode_service>())
187187 {
188188 // TODO: use custom allocator
189189 state_ = svc_.create_instance (nullptr , nullptr , nullptr );
@@ -292,13 +292,61 @@ serializer::
292292
293293serializer::
294294serializer (
295- serializer&&) noexcept = default ;
295+ serializer&& other) noexcept
296+ : ctx_(other.ctx_)
297+ , ws_(std::move(other.ws_))
298+ , filter_(other.filter_)
299+ , buf_gen_(other.buf_gen_)
300+ , source_(other.source_)
301+ , out_(other.out_)
302+ , in_(other.in_)
303+ , prepped_(other.prepped_)
304+ , tmp_(other.tmp_)
305+ , st_(other.st_)
306+ , chunk_header_len_(other.chunk_header_len_)
307+ , more_input_(other.more_input_)
308+ , is_done_(other.is_done_)
309+ , is_header_done_(other.is_header_done_)
310+ , is_chunked_(other.is_chunked_)
311+ , needs_exp100_continue_(other.needs_exp100_continue_)
312+ , filter_done_(other.filter_done_)
313+ {
314+ other.is_done_ = true ;
315+ }
296316
317+ serializer&
297318serializer::
298- serializer (rts::context& ctx)
299- : ctx_(ctx)
300- , svc_(ctx.get_service<serializer_service>())
301- , ws_(svc_.space_needed)
319+ operator =(
320+ serializer&& other) noexcept
321+ {
322+ ctx_ = other.ctx_ ;
323+ ws_ = std::move (other.ws_ );
324+ filter_ = other.filter_ ;
325+ buf_gen_ = other.buf_gen_ ;
326+ source_ = other.source_ ;
327+ out_ = other.out_ ;
328+ in_ = other.in_ ;
329+ prepped_ = other.prepped_ ;
330+ tmp_ = other.tmp_ ;
331+ st_ = other.st_ ;
332+ chunk_header_len_ = other.chunk_header_len_ ;
333+ more_input_ = other.more_input_ ;
334+ is_done_ = other.is_done_ ;
335+ is_header_done_ = other.is_header_done_ ;
336+ is_chunked_ = other.is_chunked_ ;
337+ needs_exp100_continue_ = other.needs_exp100_continue_ ;
338+ filter_done_ = other.filter_done_ ;
339+
340+ other.is_done_ = true ;
341+
342+ return *this ;
343+ }
344+
345+ serializer::
346+ serializer (const rts::context& ctx)
347+ : ctx_(&ctx)
348+ , ws_(ctx_->get_service<
349+ serializer_service>().space_needed)
302350 , is_done_(true )
303351{
304352}
@@ -609,8 +657,8 @@ consume(
609657 if (needs_exp100_continue_)
610658 return ;
611659
612- ws_. clear ();
613- is_done_ = true ;
660+ // ready for next message
661+ reset () ;
614662}
615663
616664// ------------------------------------------------
@@ -653,41 +701,44 @@ start_init(
653701 // Transfer-Encoding
654702 is_chunked_ = md.transfer_encoding .is_chunked ;
655703
704+ auto & cfg = ctx_->get_service <
705+ serializer_service>().cfg ;
706+
656707 // Content-Encoding
657708 switch (md.content_encoding .coding )
658709 {
659710 case content_coding::deflate:
660- if (!svc_. cfg .apply_deflate_encoder )
711+ if (!cfg.apply_deflate_encoder )
661712 goto no_filter;
662713 filter_ = &ws_.emplace <zlib_filter>(
663714 ctx_,
664715 ws_,
665- svc_. cfg .zlib_comp_level ,
666- svc_. cfg .zlib_window_bits ,
667- svc_. cfg .zlib_mem_level );
716+ cfg.zlib_comp_level ,
717+ cfg.zlib_window_bits ,
718+ cfg.zlib_mem_level );
668719 filter_done_ = false ;
669720 break ;
670721
671722 case content_coding::gzip:
672- if (!svc_. cfg .apply_gzip_encoder )
723+ if (!cfg.apply_gzip_encoder )
673724 goto no_filter;
674725 filter_ = &ws_.emplace <zlib_filter>(
675726 ctx_,
676727 ws_,
677- svc_. cfg .zlib_comp_level ,
678- svc_. cfg .zlib_window_bits + 16 ,
679- svc_. cfg .zlib_mem_level );
728+ cfg.zlib_comp_level ,
729+ cfg.zlib_window_bits + 16 ,
730+ cfg.zlib_mem_level );
680731 filter_done_ = false ;
681732 break ;
682733
683734 case content_coding::br:
684- if (!svc_. cfg .apply_brotli_encoder )
735+ if (!cfg.apply_brotli_encoder )
685736 goto no_filter;
686737 filter_ = &ws_.emplace <brotli_filter>(
687738 ctx_,
688739 ws_,
689- svc_. cfg .brotli_comp_quality ,
690- svc_. cfg .brotli_comp_window );
740+ cfg.brotli_comp_quality ,
741+ cfg.brotli_comp_window );
691742 filter_done_ = false ;
692743 break ;
693744
0 commit comments