@@ -58,8 +58,7 @@ class FoxyClient : public Client,
58
58
read_timeout_(read_timeout),
59
59
write_timeout_(write_timeout),
60
60
req_(std::move(req)),
61
- body_parser_(),
62
- session_(executor,
61
+ session_(std::move(executor),
63
62
foxy::session_opts{ToOptRef (ssl_context_),
64
63
connect_timeout.value_or (kNoTimeout )}),
65
64
logger_ (std::move(logger)) {
@@ -69,7 +68,7 @@ class FoxyClient : public Client,
69
68
body_parser_.get ().body ().on_event (std::move (receiver));
70
69
}
71
70
72
- void fail (boost::system::error_code ec, std::string what) {
71
+ void fail (boost::system::error_code ec, std::string const & what) {
73
72
logger_ (" sse-client: " + what + " : " + ec.message ());
74
73
async_shutdown (nullptr );
75
74
}
@@ -83,12 +82,11 @@ class FoxyClient : public Client,
83
82
84
83
void async_shutdown (std::function<void ()> completion) override {
85
84
session_.async_shutdown (beast::bind_front_handler (
86
- &FoxyClient::on_shutdown, shared_from_this (),
87
- std::move (completion)));
85
+ &FoxyClient::on_shutdown, std::move (completion)));
88
86
}
89
87
90
- void on_shutdown (std::function<void ()> completion,
91
- boost::system::error_code ec) {
88
+ static void on_shutdown (std::function<void ()> completion,
89
+ boost::system::error_code ec) {
92
90
boost::ignore_unused (ec);
93
91
if (completion) {
94
92
completion ();
@@ -229,15 +227,15 @@ std::shared_ptr<Client> Builder::build() {
229
227
230
228
auto request = request_;
231
229
232
- // Don 't send a body unless the method is POST or REPORT
233
- if (!( request.method () == http::verb::post ||
234
- request.method () == http::verb::report) ) {
230
+ // If this isn 't a post or report, ensure the body is empty.
231
+ if (request.method () != http::verb::post &&
232
+ request.method () != http::verb::report) {
235
233
request.body () = " " ;
236
234
} else {
237
235
// If it is, then setup Content-Type, only if one wasn't
238
236
// specified.
239
- if (auto it = request.find (http::field::content_type);
240
- it == request.end ()) {
237
+ if (auto content_header = request.find (http::field::content_type);
238
+ content_header == request.end ()) {
241
239
request.set (http::field::content_type, " text/plain" );
242
240
}
243
241
}
@@ -247,7 +245,7 @@ std::shared_ptr<Client> Builder::build() {
247
245
std::string host = uri_components->host ();
248
246
249
247
request.set (http::field::host, host);
250
- request.target (uri_components->path ());
248
+ request.target (uri_components->encoded_target ());
251
249
252
250
std::string service = uri_components->has_port () ? uri_components->port ()
253
251
: uri_components->scheme ();
0 commit comments