Skip to content

Refactored HTTP client v2. #476

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jan 2, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Minor refactoring in the HTTP client.
  • Loading branch information
glynos committed Dec 24, 2014
commit e2da30516c3855f52ce81013f024d2c0161ffbeb
14 changes: 8 additions & 6 deletions http/src/http/v2/client/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ namespace network {

void read_response_status(const boost::system::error_code &ec,
std::size_t bytes_written,
std::shared_ptr<request_context> context,
std::shared_ptr<response> res);
std::shared_ptr<request_context> context);

void read_response_headers(const boost::system::error_code &ec,
std::size_t bytes_read,
Expand Down Expand Up @@ -299,19 +298,17 @@ namespace network {
}

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

void client::impl::read_response_status(
const boost::system::error_code &ec, std::size_t,
std::shared_ptr<request_context> context,
std::shared_ptr<response> res) {
std::shared_ptr<request_context> context) {
if (timedout_) {
set_error(boost::asio::error::timed_out, context);
return;
Expand All @@ -331,6 +328,11 @@ namespace network {
string_type message;
std::getline(is, message);

// if options_.follow_redirects()
// and if status in range 300 - 307
// then take the request and reset the URL

std::shared_ptr<response> res(new response{});
res->set_version(version);
res->set_status(network::http::v2::status::code(status));
res->set_status_message(boost::trim_copy(message));
Expand Down
2 changes: 1 addition & 1 deletion http/src/network/http/v2/client/request.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ class request {
* \brief Move constructor.
*/
request(request &&other) noexcept
: url_(std::move(other.url_))
: url_(std::move(other.url_))
, method_(std::move(other.method_))
, path_(std::move(other.path_))
, version_(std::move(other.version_))
Expand Down