File tree Expand file tree Collapse file tree 4 files changed +33
-5
lines changed
Expand file tree Collapse file tree 4 files changed +33
-5
lines changed Original file line number Diff line number Diff line change @@ -254,8 +254,7 @@ main(int, char*[])
254254 }
255255
256256 // Install serializer service with default configuration
257- http_proto::serializer::config cfg;
258- http_proto::install_serializer_service (rts_ctx, cfg);
257+ http_proto::install_serializer_service (rts_ctx, {});
259258
260259 // Root certificates used for verification
261260 ssl_ctx.set_default_verify_paths ();
Original file line number Diff line number Diff line change @@ -166,8 +166,7 @@ main(int, char*[])
166166 }
167167
168168 // Install serializer service with default configuration
169- http_proto::serializer::config cfg;
170- http_proto::install_serializer_service (rts_ctx, cfg);
169+ http_proto::install_serializer_service (rts_ctx, {});
171170
172171 // Root certificates used for verification
173172 ssl_ctx.set_default_verify_paths ();
Original file line number Diff line number Diff line change @@ -223,6 +223,33 @@ class stream_impl : public any_stream
223223 };
224224};
225225
226+ class json_sink : public http_proto ::sink
227+ {
228+ json::stream_parser& jpr_;
229+
230+ public:
231+ json_sink (json::stream_parser& jpr)
232+ : jpr_(jpr)
233+ {
234+ }
235+
236+ private:
237+ results
238+ on_write (
239+ buffers::const_buffer b,
240+ bool more) override
241+ {
242+ results ret;
243+ ret.bytes = jpr_.write (
244+ static_cast <const char *>(b.data ()),
245+ b.size (),
246+ ret.ec );
247+ if (!ret.ec && !more)
248+ jpr_.finish (ret.ec );
249+ return ret;
250+ }
251+ };
252+
226253} // namespace
227254
228255// ----------------------------------------------
@@ -287,12 +314,13 @@ class client::request_op
287314 http_io::async_read_header (
288315 *c_.stream_ , c_.pr_ , std::move (self));
289316
317+ c_.pr_ .set_body <json_sink>(c_.jpr_ );
290318 BOOST_ASIO_CORO_YIELD
291319 http_io::async_read (
292320 *c_.stream_ , c_.pr_ , std::move (self));
293321
294322 {
295- auto body = json::parse ( c_.pr_ . body (), ec );
323+ auto body = c_.jpr_ . release ( );
296324 if (ec || !body.is_object ())
297325 return self.complete ({ errc::invalid_response }, {});
298326 auto & obj = body.get_object ();
Original file line number Diff line number Diff line change 2222#include < boost/http_proto/request.hpp>
2323#include < boost/http_proto/response_parser.hpp>
2424#include < boost/http_proto/serializer.hpp>
25+ #include < boost/json/stream_parser.hpp>
2526#include < boost/json/value_to.hpp>
2627#include < boost/rts/context_fwd.hpp>
2728#include < boost/url/url.hpp>
@@ -36,6 +37,7 @@ class client
3637 boost::http_proto::serializer sr_;
3738 boost::http_proto::response_parser pr_;
3839 boost::http_proto::request req_;
40+ boost::json::stream_parser jpr_;
3941 std::uint64_t id_ = 0 ;
4042
4143public:
You can’t perform that action at this time.
0 commit comments