11
11
12
12
#include < iterator>
13
13
#include < cstdint>
14
- #include < iostream>
15
14
#include < boost/algorithm/string/trim.hpp>
16
15
#include < boost/asio/steady_timer.hpp>
17
16
#include < boost/asio/placeholders.hpp>
@@ -48,10 +47,10 @@ struct chunk_encoding_parser {
48
47
size_t chunk_size;
49
48
std::array<typename char_<Tag>::type,1024 > buffer;
50
49
51
- void update_chunk_size (boost::iterator_range< typename std::array<
52
- typename char_<Tag>::type, 1024 >::const_iterator> const &range) {
53
- if ( range. empty ())
54
- return ;
50
+ void update_chunk_size (
51
+ boost::iterator_range< typename std::array<
52
+ typename char_<Tag>::type, 1024 >::const_iterator> const & range) {
53
+ if (range. empty ()) return ;
55
54
std::stringstream ss;
56
55
ss << std::hex << range;
57
56
size_t size;
@@ -61,15 +60,15 @@ struct chunk_encoding_parser {
61
60
}
62
61
63
62
boost::iterator_range<
64
- typename std::array<typename char_<Tag>::type,1024 >::const_iterator>
65
- operator ()(boost::iterator_range<typename std::array<
66
- typename char_<Tag>::type,1024 >::const_iterator>const &range) {
63
+ typename std::array<typename char_<Tag>::type,1024 >::const_iterator>
64
+ operator ()(
65
+ boost::iterator_range<typename std::array<
66
+ typename char_<Tag>::type,1024 >::const_iterator>const &range) {
67
67
auto iter =boost::begin (range);
68
68
auto begin = iter;
69
69
auto pos =boost::begin (buffer);
70
70
71
- while (iter !=boost::end (range))
72
- switch (state) {
71
+ while (iter !=boost::end (range))switch (state) {
73
72
case state_t ::header:
74
73
iter =std::find (iter,boost::end (range),' \r ' );
75
74
update_chunk_size (boost::make_iterator_range (begin, iter));
@@ -485,19 +484,22 @@ struct http_async_connection
485
484
string_type body_string;
486
485
if (this ->is_chunk_encoding && remove_chunk_markers_) {
487
486
for (size_t i =0 ; i <this ->partial_parsed .size (); i +=1024 ) {
488
- auto range =parse_chunk_encoding (
489
- boost::make_iterator_range (this ->partial_parsed .data () + i,
490
- this ->partial_parsed .data () +std::min (i+1024 ,this ->partial_parsed .size ())));
487
+ auto range =parse_chunk_encoding (boost::make_iterator_range (
488
+ this ->partial_parsed .data () + i,
489
+ this ->partial_parsed .data () +
490
+ std::min (i +1024 ,this ->partial_parsed .size ())));
491
491
body_string.append (boost::begin (range),boost::end (range));
492
492
}
493
493
this ->partial_parsed .clear ();
494
- auto range =parse_chunk_encoding (boost::make_iterator_range (this ->part .begin (),
495
- this ->part .begin () + bytes_transferred));
494
+ auto range =parse_chunk_encoding (boost::make_iterator_range (
495
+ this ->part .begin (),
496
+ this ->part .begin () + bytes_transferred));
496
497
body_string.append (boost::begin (range),boost::end (range));
497
498
this ->body_promise .set_value (body_string);
498
499
}else {
499
500
std::swap (body_string,this ->partial_parsed );
500
- body_string.append (this ->part .begin (),this ->part .begin () + bytes_transferred);
501
+ body_string.append (this ->part .begin (),
502
+ this ->part .begin () + bytes_transferred);
501
503
this ->body_promise .set_value (body_string);
502
504
}
503
505
}