Skip to content

Commit e2da305

Browse files
committed
Minor refactoring in the HTTP client.
1 parent 50f3a4c commit e2da305

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

http/src/http/v2/client/client.cpp

+8-6
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ namespace network {
8080

8181
void read_response_status(const boost::system::error_code &ec,
8282
std::size_t bytes_written,
83-
std::shared_ptr<request_context> context,
84-
std::shared_ptr<response> res);
83+
std::shared_ptr<request_context> context);
8584

8685
void read_response_headers(const boost::system::error_code &ec,
8786
std::size_t bytes_read,
@@ -299,19 +298,17 @@ namespace network {
299298
}
300299

301300
// Create a response object and fill it with the status from the server.
302-
std::shared_ptr<response> res(new response{});
303301
context->connection_->async_read_until(
304302
context->response_buffer_, "\r\n",
305303
strand_.wrap([=](const boost::system::error_code &ec,
306304
std::size_t bytes_read) {
307-
read_response_status(ec, bytes_read, context, res);
305+
read_response_status(ec, bytes_read, context);
308306
}));
309307
}
310308

311309
void client::impl::read_response_status(
312310
const boost::system::error_code &ec, std::size_t,
313-
std::shared_ptr<request_context> context,
314-
std::shared_ptr<response> res) {
311+
std::shared_ptr<request_context> context) {
315312
if (timedout_) {
316313
set_error(boost::asio::error::timed_out, context);
317314
return;
@@ -331,6 +328,11 @@ namespace network {
331328
string_type message;
332329
std::getline(is, message);
333330

331+
// if options_.follow_redirects()
332+
// and if status in range 300 - 307
333+
// then take the request and reset the URL
334+
335+
std::shared_ptr<response> res(new response{});
334336
res->set_version(version);
335337
res->set_status(network::http::v2::status::code(status));
336338
res->set_status_message(boost::trim_copy(message));

http/src/network/http/v2/client/request.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ class request {
373373
* \brief Move constructor.
374374
*/
375375
request(request &&other) noexcept
376-
: url_(std::move(other.url_))
376+
: url_(std::move(other.url_))
377377
, method_(std::move(other.method_))
378378
, path_(std::move(other.path_))
379379
, version_(std::move(other.version_))

0 commit comments

Comments
 (0)