1212#define BOOST_HTTP_PROTO_PARSER_HPP
1313
1414#include < boost/http_proto/detail/config.hpp>
15- #include < boost/http_proto/error.hpp>
16- #include < boost/http_proto/header_limits.hpp>
17- #include < boost/http_proto/sink.hpp>
1815#include < boost/http_proto/detail/header.hpp>
1916#include < boost/http_proto/detail/type_traits.hpp>
2017#include < boost/http_proto/detail/workspace.hpp>
18+ #include < boost/http_proto/error.hpp>
19+ #include < boost/http_proto/header_limits.hpp>
20+ #include < boost/http_proto/sink.hpp>
21+
22+ #include < boost/buffers/any_dynamic_buffer.hpp>
2123#include < boost/buffers/circular_buffer.hpp>
2224#include < boost/buffers/flat_buffer.hpp>
2325#include < boost/buffers/mutable_buffer_pair.hpp>
2426#include < boost/buffers/mutable_buffer_span.hpp>
2527#include < boost/buffers/type_traits.hpp>
26- #include < boost/buffers/any_dynamic_buffer.hpp>
2728#include < boost/url/grammar/error.hpp>
29+
2830#include < cstddef>
2931#include < cstdint>
30- #include < functional>
31- #include < memory>
32- #include < utility>
3332
3433namespace boost {
3534namespace http_proto {
@@ -185,7 +184,7 @@ class BOOST_SYMBOL_VISIBLE
185184 bool
186185 is_complete () const noexcept
187186 {
188- return st_ == state::complete ;
187+ return st_ >= state::complete_in_place ;
189188 }
190189
191190 /* * Returns `true` if the end of the stream was reached.
@@ -209,8 +208,7 @@ class BOOST_SYMBOL_VISIBLE
209208 {
210209 return
211210 st_ == state::reset ||
212- ( st_ == state::complete &&
213- got_eof_);
211+ (st_ >= state::complete_in_place && got_eof_);
214212 }
215213
216214 // --------------------------------------------
@@ -366,38 +364,50 @@ class BOOST_SYMBOL_VISIBLE
366364 friend class response_parser ;
367365
368366 detail::header const *
369- safe_get_header () const ;
370- bool is_plain () const noexcept ;
371- void on_headers (system::error_code&);
372- BOOST_HTTP_PROTO_DECL void on_set_body ();
373- void init_dynamic (system::error_code&);
367+ safe_get_header () const ;
368+
369+ bool
370+ is_plain () const noexcept ;
371+
372+ void
373+ on_headers (system::error_code&);
374+
375+ BOOST_HTTP_PROTO_DECL
376+ void
377+ on_set_body ();
378+
379+ std::size_t
380+ apply_filter (
381+ system::error_code&,
382+ std::size_t ,
383+ bool );
374384
375385 static constexpr unsigned buffers_N = 8 ;
376386
377387 enum class state
378388 {
379- // order matters
380389 reset,
381390 start,
382391 header,
383392 body,
384393 set_body,
394+ complete_in_place,
385395 complete
386396 };
387397
388398 enum class how
389399 {
390400 in_place,
401+ sink,
391402 elastic,
392- sink
393403 };
394404
395405 context& ctx_;
396406 parser_service& svc_;
397407
398408 detail::workspace ws_;
399409 detail::header h_;
400- std::uint64_t body_avail_ = 0 ;
410+ std::size_t body_avail_ = 0 ;
401411 std::uint64_t body_total_ = 0 ;
402412 std::uint64_t payload_remain_ = 0 ;
403413 std::uint64_t chunk_remain_ = 0 ;
@@ -421,18 +431,17 @@ class BOOST_SYMBOL_VISIBLE
421431 // `const_buffers_type` from relevant functions
422432 buffers::const_buffer_pair cbp_;
423433
424- buffers::circular_buffer* body_buf_ = nullptr ;
425434 buffers::any_dynamic_buffer* eb_ = nullptr ;
426435 detail::filter* filter_ = nullptr ;
427436 sink* sink_ = nullptr ;
428437
429438 state st_ = state::start;
430439 how how_ = how::in_place;
431440 bool got_eof_ = false ;
432- // bool need_more_;
433441 bool head_response_ = false ;
434442 bool needs_chunk_close_ = false ;
435443 bool trailer_headers_ = false ;
444+ bool chunked_body_ended = false ;
436445};
437446
438447// ------------------------------------------------
0 commit comments