@@ -218,29 +218,7 @@ namespace boost { namespace network { namespace http {
218
218
template <class ConstBufferSeq , class Callback >
219
219
void write_vec (ConstBufferSeq const & seq, Callback const & callback)
220
220
{
221
- lock_guard lock (headers_mutex);
222
- if (error_encountered)
223
- boost::throw_exception (boost::system::system_error (*error_encountered));
224
-
225
- boost::function<void ()> continuation = boost::bind (
226
- &async_connection<Tag,Handler>::write_vec<ConstBufferSeq, Callback>
227
- ,async_connection<Tag,Handler>::shared_from_this ()
228
- ,seq, callback
229
- );
230
-
231
- if (!headers_already_sent && !headers_in_progress) {
232
- write_headers_only (continuation);
233
- return ;
234
- } else if (headers_in_progress && !headers_already_sent) {
235
- pending_actions.push_back (continuation);
236
- return ;
237
- }
238
-
239
- asio::async_write (
240
- socket_
241
- ,seq
242
- ,boost::bind (callback, asio::placeholders::error)
243
- );
221
+ write_vec_impl (seq, callback, shared_array_list (), shared_buffers ());
244
222
}
245
223
246
224
private:
@@ -537,15 +515,6 @@ namespace boost { namespace network { namespace http {
537
515
538
516
void do_nothing () {}
539
517
540
- template <class Range >
541
- void continue_write (Range range, boost::function<void (boost::system::error_code)> callback) {
542
- thread_pool ().post (
543
- boost::bind (
544
- &async_connection<Tag,Handler>::write_impl<Range>
545
- , async_connection<Tag,Handler>::shared_from_this ()
546
- , range, callback));
547
- }
548
-
549
518
template <class Callback >
550
519
void write_first_line (Callback callback) {
551
520
lock_guard lock (headers_mutex);
@@ -630,27 +599,6 @@ namespace boost { namespace network { namespace http {
630
599
631
600
template <class Range >
632
601
void write_impl (Range range, boost::function<void (boost::system::error_code)> callback) {
633
- lock_guard lock (headers_mutex);
634
- boost::function<void (boost::system::error_code)> callback_function =
635
- callback;
636
-
637
- if (!headers_already_sent && !headers_in_progress) {
638
- write_headers_only (
639
- boost::bind (
640
- &async_connection<Tag,Handler>::continue_write<Range>
641
- , async_connection<Tag,Handler>::shared_from_this ()
642
- , range, callback_function
643
- ));
644
- return ;
645
- } else if (headers_in_progress && !headers_already_sent) {
646
- pending_actions.push_back (
647
- boost::bind (
648
- &async_connection<Tag,Handler>::continue_write<Range>
649
- , async_connection<Tag,Handler>::shared_from_this ()
650
- , range, callback_function));
651
- return ;
652
- }
653
-
654
602
// linearize the whole range into a vector
655
603
// of fixed-sized buffers, then schedule an asynchronous
656
604
// write of these buffers -- make sure they are live
@@ -697,25 +645,47 @@ namespace boost { namespace network { namespace http {
697
645
}
698
646
699
647
if (!buffers->empty ()) {
700
- boost::function<void (boost::system::error_code const &)> f = callback;
701
- asio::async_write (
702
- socket_
703
- , *buffers
704
- , strand.wrap (
705
- boost::bind (
706
- &async_connection<Tag,Handler>::handle_write
707
- , async_connection<Tag,Handler>::shared_from_this ()
708
- , f
709
- , temporaries
710
- , buffers // keep these alive until the handler is called!
711
- , boost::asio::placeholders::error
712
- , boost::asio::placeholders::bytes_transferred
713
- )
714
- )
715
- );
648
+ write_vec_impl (*buffers, callback, temporaries, buffers);
716
649
}
717
650
}
718
651
652
+ template <class ConstBufferSeq , class Callback >
653
+ void write_vec_impl (ConstBufferSeq const & seq
654
+ ,Callback const & callback
655
+ ,shared_array_list temporaries
656
+ ,shared_buffers buffers)
657
+ {
658
+ lock_guard lock (headers_mutex);
659
+ if (error_encountered)
660
+ boost::throw_exception (boost::system::system_error (*error_encountered));
661
+
662
+ boost::function<void ()> continuation = boost::bind (
663
+ &async_connection<Tag,Handler>::write_vec_impl<ConstBufferSeq, Callback>
664
+ ,async_connection<Tag,Handler>::shared_from_this ()
665
+ ,seq, callback, temporaries, buffers
666
+ );
667
+
668
+ if (!headers_already_sent && !headers_in_progress) {
669
+ write_headers_only (continuation);
670
+ return ;
671
+ } else if (headers_in_progress && !headers_already_sent) {
672
+ pending_actions.push_back (continuation);
673
+ return ;
674
+ }
675
+
676
+ asio::async_write (
677
+ socket_
678
+ ,seq
679
+ ,boost::bind (
680
+ &async_connection<Tag,Handler>::handle_write
681
+ ,async_connection<Tag,Handler>::shared_from_this ()
682
+ ,callback
683
+ ,temporaries
684
+ ,buffers
685
+ ,asio::placeholders::error
686
+ ,asio::placeholders::bytes_transferred)
687
+ );
688
+ }
719
689
};
720
690
721
691
} /* http */
0 commit comments