Skip to content
Prev Previous commit
Next Next commit
Nicer formatting and clean ups
  • Loading branch information
umennel committed Mar 31, 2018
commit 76b4ebf31c718b434330e2187cf4f28163656ef7
34 changes: 18 additions & 16 deletions boost/network/protocol/http/client/connection/async_normal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

#include <iterator>
#include <cstdint>
#include <iostream>
#include <boost/algorithm/string/trim.hpp>
#include <boost/asio/steady_timer.hpp>
#include <boost/asio/placeholders.hpp>
Expand Down Expand Up @@ -48,10 +47,10 @@ struct chunk_encoding_parser {
size_t chunk_size;
std::array<typename char_<Tag>::type, 1024> buffer;

void update_chunk_size(boost::iterator_range<typename std::array<
typename char_<Tag>::type, 1024>::const_iterator> const &range) {
if (range.empty())
return;
void update_chunk_size(
boost::iterator_range<typename std::array<
typename char_<Tag>::type, 1024>::const_iterator> const &range) {
if (range.empty()) return;
std::stringstream ss;
ss << std::hex << range;
size_t size;
Expand All @@ -61,15 +60,15 @@ struct chunk_encoding_parser {
}

boost::iterator_range<
typename std::array<typename char_<Tag>::type, 1024>::const_iterator>
operator()(boost::iterator_range<typename std::array<
typename char_<Tag>::type, 1024>::const_iterator> const &range) {
typename std::array<typename char_<Tag>::type, 1024>::const_iterator>
operator()(
boost::iterator_range<typename std::array<
typename char_<Tag>::type, 1024>::const_iterator> const &range) {
auto iter = boost::begin(range);
auto begin = iter;
auto pos = boost::begin(buffer);

while (iter != boost::end(range))
switch (state) {
while (iter != boost::end(range)) switch (state) {
case state_t::header:
iter = std::find(iter, boost::end(range), '\r');
update_chunk_size(boost::make_iterator_range(begin, iter));
Expand Down Expand Up @@ -485,19 +484,22 @@ struct http_async_connection
string_type body_string;
if (this->is_chunk_encoding && remove_chunk_markers_) {
for (size_t i = 0; i < this->partial_parsed.size(); i += 1024) {
auto range = parse_chunk_encoding(
boost::make_iterator_range(this->partial_parsed.data() + i,
this->partial_parsed.data() + std::min(i+1024, this->partial_parsed.size())));
auto range = parse_chunk_encoding(boost::make_iterator_range(
this->partial_parsed.data() + i,
this->partial_parsed.data() +
std::min(i + 1024, this->partial_parsed.size())));
body_string.append(boost::begin(range), boost::end(range));
}
this->partial_parsed.clear();
auto range = parse_chunk_encoding(boost::make_iterator_range(this->part.begin(),
this->part.begin() + bytes_transferred));
auto range = parse_chunk_encoding(boost::make_iterator_range(
this->part.begin(),
this->part.begin() + bytes_transferred));
body_string.append(boost::begin(range), boost::end(range));
this->body_promise.set_value(body_string);
} else {
std::swap(body_string, this->partial_parsed);
body_string.append(this->part.begin(), this->part.begin() + bytes_transferred);
body_string.append(this->part.begin(),
this->part.begin() + bytes_transferred);
this->body_promise.set_value(body_string);
}
}
Expand Down
6 changes: 3 additions & 3 deletions boost/network/protocol/http/policies/async_connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ struct async_connection_policy : resolver_policy<Tag>::type {
optional<string_type> const& sni_hostname, long ssl_options) {
pimpl = impl::async_connection_base<Tag, version_major, version_minor>::
new_connection(resolve, resolver, follow_redirect, always_verify_peer,
https, timeout, remove_chunk_markers, certificate_filename,
verify_path, certificate_file, private_key_file, ciphers,
sni_hostname, ssl_options);
https, timeout, remove_chunk_markers,
certificate_filename, verify_path, certificate_file,
private_key_file, ciphers, sni_hostname, ssl_options);
}

basic_response<Tag> send_request(string_type /*unused*/ const& method,
Expand Down