Skip to content

Commit 83ed388

Browse files
umenneldeanberris
authored andcommitted
Removed commented lines.
1 parent eb907a8 commit 83ed388

File tree

1 file changed

+16
-38
lines changed

1 file changed

+16
-38
lines changed

boost/network/protocol/http/client/connection/async_normal.hpp

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,11 @@ struct http_async_connection
433433

434434
// The invocation of the callback is synchronous to allow us to
435435
// wait before scheduling another read.
436-
callback(make_iterator_range(begin, end), ec);
437-
436+
if (this->is_chunk_encoding && remove_chunk_markers_) {
437+
callback(parse_chunk_encoding(make_iterator_range(begin, end)), ec);
438+
} else {
439+
callback(make_iterator_range(begin, end), ec);
440+
}
438441
auto self = this->shared_from_this();
439442
delegate_->read_some(
440443
boost::asio::mutable_buffers_1(this->part.data(),
@@ -473,7 +476,11 @@ struct http_async_connection
473476
// We call the callback function synchronously passing the error
474477
// condition (in this case, end of file) so that it can handle it
475478
// appropriately.
476-
callback(make_iterator_range(begin, end), ec);
479+
if (this->is_chunk_encoding && remove_chunk_markers_) {
480+
callback(parse_chunk_encoding(make_iterator_range(begin, end)), ec);
481+
} else {
482+
callback(make_iterator_range(begin, end), ec);
483+
}
477484
} else {
478485
string_type body_string;
479486
if (this->is_chunk_encoding && remove_chunk_markers_) {
@@ -490,9 +497,7 @@ struct http_async_connection
490497
this->body_promise.set_value(body_string);
491498
} else {
492499
std::swap(body_string, this->partial_parsed);
493-
auto it = this->part.begin();
494-
std::advance(it, bytes_transferred);
495-
body_string.append(this->part.begin(), it);
500+
body_string.append(this->part.begin(), this->part.begin() + bytes_transferred);
496501
this->body_promise.set_value(body_string);
497502
}
498503
}
@@ -514,7 +519,11 @@ struct http_async_connection
514519
this->part.begin();
515520
typename protocol_base::buffer_type::const_iterator end = begin;
516521
std::advance(end, bytes_transferred);
517-
callback(make_iterator_range(begin, end), ec);
522+
if (this->is_chunk_encoding && remove_chunk_markers_) {
523+
callback(parse_chunk_encoding(make_iterator_range(begin, end)), ec);
524+
} else {
525+
callback(make_iterator_range(begin, end), ec);
526+
}
518527
auto self = this->shared_from_this();
519528
delegate_->read_some(
520529
boost::asio::mutable_buffers_1(this->part.data(),
@@ -577,37 +586,6 @@ struct http_async_connection
577586
}
578587
}
579588

580-
string_type parse_chunk_encoding(string_type& body_string) {
581-
string_type body;
582-
string_type crlf = "\r\n";
583-
584-
typename string_type::iterator begin = body_string.begin();
585-
for (typename string_type::iterator iter =
586-
std::search(begin, body_string.end(), crlf.begin(), crlf.end());
587-
iter != body_string.end();
588-
iter =
589-
std::search(begin, body_string.end(), crlf.begin(), crlf.end())) {
590-
string_type line(begin, iter);
591-
if (line.empty()) {
592-
break;
593-
}
594-
std::stringstream stream(line);
595-
int len;
596-
stream >> std::hex >> len;
597-
std::advance(iter, 2);
598-
if (len == 0) {
599-
break;
600-
}
601-
if (len <= body_string.end() - iter) {
602-
body.insert(body.end(), iter, iter + len);
603-
std::advance(iter, len + 2);
604-
}
605-
begin = iter;
606-
}
607-
608-
return body;
609-
}
610-
611589
int timeout_;
612590
bool remove_chunk_markers_;
613591
boost::asio::steady_timer timer_;

0 commit comments

Comments
 (0)