@@ -121,9 +121,8 @@ void protocol_bitcoind_rpc::handle_receive_post(const code& ec,
121121 return ;
122122 }
123123
124- using json_t = json_body::value_type;
125124 const auto & body = post ->body ();
126- if (!body.contains <json_t >())
125+ if (!body.contains <json_body::value_type >())
127126 {
128127 send_not_acceptable (*post );
129128 return ;
@@ -132,7 +131,7 @@ void protocol_bitcoind_rpc::handle_receive_post(const code& ec,
132131 request_t request{};
133132 try
134133 {
135- request = value_to<request_t >(body.get <json_t >().model );
134+ request = value_to<request_t >(body.get <json_body::value_type >().model );
136135 }
137136 catch (const boost::system::system_error& e)
138137 {
@@ -145,7 +144,10 @@ void protocol_bitcoind_rpc::handle_receive_post(const code& ec,
145144 return ;
146145 }
147146
147+ // The post is saved off during asynchonous handling and used in send_json
148+ // to formulate response headers, isolating handlers from http semantics.
148149 set_post (post );
150+
149151 if (const auto code = dispatcher_.notify (request))
150152 stop (code);
151153}
@@ -283,18 +285,6 @@ bool protocol_bitcoind_rpc::handle_verify_tx_out_set(const code& ec,
283285// private
284286// ----------------------------------------------------------------------------
285287
286- void protocol_bitcoind_rpc::set_post (const post ::cptr& post ) NOEXCEPT
287- {
288- BC_ASSERT (post );
289- post_ = post ;
290- }
291-
292- const protocol_bitcoind_rpc::post & protocol_bitcoind_rpc::get_post () const NOEXCEPT
293- {
294- BC_ASSERT (post_);
295- return *post_;
296- }
297-
298288// TODO: post-process response for json-rpc version.
299289void protocol_bitcoind_rpc::send_json (boost::json::value&& model,
300290 size_t size_hint) NOEXCEPT
@@ -311,6 +301,18 @@ void protocol_bitcoind_rpc::send_json(boost::json::value&& model,
311301 SEND (std::move (response), handle_complete, _1, error::success);
312302}
313303
304+ void protocol_bitcoind_rpc::set_post (const post ::cptr& post ) NOEXCEPT
305+ {
306+ BC_ASSERT (post );
307+ post_ = post ;
308+ }
309+
310+ const protocol_bitcoind_rpc::post & protocol_bitcoind_rpc::get_post () const NOEXCEPT
311+ {
312+ BC_ASSERT (post_);
313+ return *post_;
314+ }
315+
314316BC_POP_WARNING ()
315317BC_POP_WARNING ()
316318BC_POP_WARNING ()
0 commit comments