@@ -253,8 +253,7 @@ namespace boost { namespace network { namespace http { namespace impl {
253
253
version.append (boost::begin (result_range), boost::end (result_range));
254
254
algorithm::trim (version);
255
255
version_promise.set_value (version);
256
- typename buffer_type::const_iterator end = part.end ();
257
- std::copy (boost::end (result_range), end, part.begin ());
256
+ part_begin = boost::end (result_range);
258
257
this ->parse_status ();
259
258
} else if (parsed_ok == false ) {
260
259
std::runtime_error error (" Invalid Version Part." );
@@ -267,9 +266,10 @@ namespace boost { namespace network { namespace http { namespace impl {
267
266
body_promise.set_exception (boost::copy_exception (error));
268
267
} else {
269
268
partial_parsed.append (
270
- part. begin (),
271
- part. end ()
269
+ boost:: begin (result_range ),
270
+ boost:: end (result_range )
272
271
);
272
+ part_begin = part.begin ();
273
273
boost::asio::async_read (
274
274
*socket_,
275
275
boost::asio::mutable_buffers_1 (part.c_array (), part.size ()),
@@ -298,19 +298,20 @@ namespace boost { namespace network { namespace http { namespace impl {
298
298
299
299
void parse_status () {
300
300
logic::tribool parsed_ok;
301
- typename boost::iterator_range<typename buffer_type::const_iterator> result_range;
301
+ typename buffer_type::const_iterator part_end = part.end ();
302
+ typename boost::iterator_range<typename buffer_type::const_iterator> result_range,
303
+ input_range = boost::make_iterator_range (part_begin, part_end);
302
304
fusion::tie (parsed_ok, result_range) = response_parser_.parse_until (
303
305
response_parser_type::http_status_done,
304
- part );
306
+ input_range );
305
307
if (parsed_ok == true ) {
306
308
string_type status;
307
309
std::swap (status, partial_parsed);
308
310
status.append (boost::begin (result_range), boost::end (result_range));
309
311
trim (status);
310
312
boost::uint16_t status_int = lexical_cast<boost::uint16_t >(status);
311
313
status_promise.set_value (status_int);
312
- typename buffer_type::const_iterator end = part.end ();
313
- std::copy (boost::end (result_range), end, part.begin ());
314
+ part_begin = boost::end (result_range);
314
315
this ->parse_status_message ();
315
316
} else if (parsed_ok == false ) {
316
317
std::runtime_error error (" Invalid status part." );
@@ -321,7 +322,11 @@ namespace boost { namespace network { namespace http { namespace impl {
321
322
destination_promise.set_exception (boost::copy_exception (error));
322
323
body_promise.set_exception (boost::copy_exception (error));
323
324
} else {
324
- partial_parsed.append (part.begin (), part.end ());
325
+ partial_parsed.append (
326
+ boost::begin (result_range),
327
+ boost::end (result_range)
328
+ );
329
+ part_begin = part.begin ();
325
330
boost::asio::async_read (*socket_,
326
331
boost::asio::mutable_buffers_1 (part.c_array (), part.size ()),
327
332
request_strand_->wrap (
@@ -348,18 +353,19 @@ namespace boost { namespace network { namespace http { namespace impl {
348
353
349
354
void parse_status_message () {
350
355
logic::tribool parsed_ok;
351
- typename boost::iterator_range<typename buffer_type::const_iterator> result_range;
356
+ typename buffer_type::const_iterator part_end = part.end ();
357
+ typename boost::iterator_range<typename buffer_type::const_iterator> result_range,
358
+ input_range = boost::make_iterator_range (part_begin, part_end);
352
359
fusion::tie (parsed_ok, result_range) = response_parser_.parse_until (
353
360
response_parser_type::http_status_message_done,
354
- part );
361
+ input_range );
355
362
if (parsed_ok == true ) {
356
363
string_type status_message;
357
364
std::swap (status_message, partial_parsed);
358
365
status_message.append (boost::begin (result_range), boost::end (result_range));
359
366
algorithm::trim (status_message);
360
367
status_message_promise.set_value (status_message);
361
- typename buffer_type::const_iterator end = part.end ();
362
- std::copy (boost::end (result_range), end, part.c_array ());
368
+ part_begin = boost::end (result_range);
363
369
this ->parse_headers ();
364
370
} else if (parsed_ok == false ) {
365
371
std::runtime_error error (" Invalid status message part." );
@@ -369,7 +375,10 @@ namespace boost { namespace network { namespace http { namespace impl {
369
375
destination_promise.set_exception (boost::copy_exception (error));
370
376
body_promise.set_exception (boost::copy_exception (error));
371
377
} else {
372
- partial_parsed.append (part.begin (), part.end ());
378
+ partial_parsed.append (
379
+ boost::begin (result_range),
380
+ boost::end (result_range));
381
+ part_begin = part.begin ();
373
382
boost::asio::async_read (
374
383
*socket_,
375
384
boost::asio::mutable_buffers_1 (part.c_array (), part.size ()),
@@ -433,22 +442,24 @@ namespace boost { namespace network { namespace http { namespace impl {
433
442
434
443
void parse_headers () {
435
444
logic::tribool parsed_ok;
436
- typename boost::iterator_range<typename buffer_type::const_iterator> result_range;
445
+ typename buffer_type::const_iterator part_end = part.end ();
446
+ typename boost::iterator_range<typename buffer_type::const_iterator> result_range,
447
+ input_range = boost::make_iterator_range (part_begin, part_end);
437
448
fusion::tie (parsed_ok, result_range) = response_parser_.parse_until (
438
449
response_parser_type::http_headers_done,
439
- part );
450
+ input_range );
440
451
if (parsed_ok == true ) {
441
452
string_type headers_string;
442
453
std::swap (headers_string, partial_parsed);
443
454
headers_string.append (boost::begin (result_range), boost::end (result_range));
444
- typename buffer_type::const_iterator end = part.end ();
445
- std::copy (boost::end (result_range), end, part.begin ());
455
+ part_begin = boost::end (result_range);
446
456
this ->parse_headers_real (headers_string);
447
- this ->parse_body (std::distance (boost::end (result_range), end ));
457
+ this ->parse_body (std::distance (boost::end (result_range), part_end ));
448
458
} else if (parsed_ok == false ) {
449
459
std::runtime_error error (" Invalid header part." );
450
460
} else {
451
- partial_parsed.append (part.begin (), part.end ());
461
+ partial_parsed.append (boost::begin (result_range), boost::end (result_range));
462
+ part_begin = part.begin ();
452
463
boost::asio::async_read (
453
464
*socket_,
454
465
boost::asio::mutable_buffers_1 (part.c_array (), part.size ()),
@@ -473,7 +484,8 @@ namespace boost { namespace network { namespace http { namespace impl {
473
484
}
474
485
475
486
void parse_body (size_t bytes) {
476
- partial_parsed.append (part.begin (), bytes);
487
+ partial_parsed.append (part_begin, bytes);
488
+ part_begin = part.begin ();
477
489
boost::asio::async_read (*socket_, boost::asio::mutable_buffers_1 (part.c_array (), part.size ()),
478
490
request_strand_->wrap (
479
491
boost::bind (
@@ -524,6 +536,7 @@ namespace boost { namespace network { namespace http { namespace impl {
524
536
string_type command_string_;
525
537
response_parser_type response_parser_;
526
538
buffer_type part;
539
+ typename buffer_type::const_iterator part_begin;
527
540
string_type partial_parsed;
528
541
string_type method;
529
542
};
0 commit comments