Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite2da305

Browse files
committed
Minor refactoring in the HTTP client.
1 parent50f3a4c commite2da305

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ namespace network {
8080

8181
voidread_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
voidread_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
voidclient::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

Lines changed: 1 addition & 1 deletion
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)

[8]ページ先頭

©2009-2025 Movatter.jp