Skip to content

Commit 435d965

Browse files
committed
[FOLD]
1 parent 9d571a6 commit 435d965

6 files changed

Lines changed: 219 additions & 311 deletions

File tree

include/boost/http_proto/parser_config.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ struct parser_config
138138
BOOST_HTTP_PROTO_DECL
139139
parser_config(role role, rts::polystore& ps);
140140

141-
auto prepare() ->
141+
auto prepare() const ->
142142
prepared_parser_config;
143143

144144
private:
@@ -167,9 +167,6 @@ struct parser_config
167167

168168
struct prepared_parser_config
169169
{
170-
prepared_parser_config(
171-
prepared_parser_config&&) = default;
172-
173170
parser_config const*
174171
operator->() const noexcept
175172
{
@@ -197,7 +194,7 @@ prepared_parser_config() = default;
197194
inline
198195
auto
199196
parser_config::
200-
prepare() ->
197+
prepare() const ->
201198
prepared_parser_config
202199
{
203200
auto sp = std::make_shared<

include/boost/http_proto/response_parser.hpp

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,41 @@ class response_parser
4141
*/
4242
response_parser() = default;
4343

44+
/** Constructor.
45+
46+
Constructs a parser that uses the @ref
47+
config parameters installed on the
48+
provided `ctx`.
49+
50+
The parser will attempt to allocate
51+
the required space on startup, with the
52+
amount depending on the @ref config
53+
parameters, and will not perform any
54+
further allocations, except for Brotli
55+
decoder instances, if enabled.
56+
57+
Depending on which compression algorithms
58+
are enabled in the @ref config, the parser
59+
will attempt to access the corresponding
60+
decoder services on the same `ctx`.
61+
62+
@par Example
63+
@code
64+
response_parser sr(ctx);
65+
@endcode
66+
67+
@par Complexity
68+
Constant.
69+
70+
@par Exception Safety
71+
Calls to allocate may throw.
72+
73+
@param cfg Configuration settings.
74+
*/
75+
BOOST_HTTP_PROTO_DECL
76+
explicit
77+
response_parser(prepared_parser_config cfg);
78+
4479
/** Constructor.
4580
4681
The states of `other` are transferred
@@ -83,44 +118,7 @@ class response_parser
83118
return *this;
84119
}
85120

86-
/** Constructor.
87-
88-
Constructs a parser that uses the @ref
89-
config parameters installed on the
90-
provided `ctx`.
91-
92-
The parser will attempt to allocate
93-
the required space on startup, with the
94-
amount depending on the @ref config
95-
parameters, and will not perform any
96-
further allocations, except for Brotli
97-
decoder instances, if enabled.
98-
99-
Depending on which compression algorithms
100-
are enabled in the @ref config, the parser
101-
will attempt to access the corresponding
102-
decoder services on the same `ctx`.
103-
104-
@par Example
105-
@code
106-
response_parser sr(ctx);
107-
@endcode
108-
109-
@par Complexity
110-
Constant.
111-
112-
@par Exception Safety
113-
Calls to allocate may throw.
114-
115-
@param cfg Configuration settings.
116-
117-
@see
118-
@ref install_parser_service,
119-
@ref config.
120-
*/
121-
BOOST_HTTP_PROTO_DECL
122-
explicit
123-
response_parser(prepared_parser_config cfg);
121+
//-------------------------------------------
124122

125123
/** Prepare for the next message on the stream.
126124

test/unit/compression.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ struct zlib_test
614614
{
615615
rts::polystore ctx;
616616
std::vector<std::string> encodings;
617-
response_parser::config cfg;
617+
parser_config cfg(role::server, ctx);
618618

619619
#ifdef BOOST_RTS_HAS_ZLIB
620620
cfg.apply_deflate_decoder = true;
@@ -632,8 +632,7 @@ struct zlib_test
632632
#endif
633633

634634
cfg.body_limit = 1024 * 1024;
635-
install_parser_service(ctx, cfg);
636-
response_parser pr(ctx);
635+
response_parser pr(cfg.prepare());
637636
pr.reset();
638637

639638
auto append_chunked = [](

0 commit comments

Comments
 (0)