25
25
#include < boost/utility/typed_in_place_factory.hpp>
26
26
#include < boost/thread/locks.hpp>
27
27
#include < boost/thread/recursive_mutex.hpp>
28
+ #include < boost/utility/enable_if.hpp>
28
29
#include < list>
29
30
#include < vector>
30
31
#include < iterator>
36
37
* This is the maximum size though and Boost.Asio's internal representation
37
38
* of a streambuf would make appropriate decisions on how big a buffer
38
39
* is to begin with.
40
+ *
41
+ * This kinda assumes that a page is by default 4096. Since we're using
42
+ * the default allocator with the static buffers, it's not guaranteed that
43
+ * the static buffers will be page-aligned when they are allocated.
39
44
*/
40
45
#define BOOST_NETWORK_HTTP_SERVER_CONNECTION_HEADER_BUFFER_MAX_SIZE 4096
41
46
#endif /* BOOST_NETWORK_HTTP_SERVER_CONNECTION_HEADER_BUFFER_MAX_SIZE */
@@ -209,14 +214,16 @@ namespace boost { namespace network { namespace http {
209
214
}
210
215
211
216
template <class Range , class Callback >
212
- void write (Range const & range, Callback const & callback) {
217
+ typename disable_if<is_base_of<asio::const_buffer, typename Range::value_type>, void >::type
218
+ write (Range const & range, Callback const & callback) {
213
219
lock_guard lock (headers_mutex);
214
220
if (error_encountered) boost::throw_exception (boost::system::system_error (*error_encountered));
215
221
write_impl (boost::make_iterator_range (range), callback);
216
222
}
217
223
218
224
template <class ConstBufferSeq , class Callback >
219
- void write_vec (ConstBufferSeq const & seq, Callback const & callback)
225
+ typename enable_if<is_base_of<asio::const_buffer, typename ConstBufferSeq::value_type>, void >::type
226
+ write (ConstBufferSeq const & seq, Callback const & callback)
220
227
{
221
228
write_vec_impl (seq, callback, shared_array_list (), shared_buffers ());
222
229
}
@@ -659,10 +666,13 @@ namespace boost { namespace network { namespace http {
659
666
if (error_encountered)
660
667
boost::throw_exception (boost::system::system_error (*error_encountered));
661
668
669
+ boost::function<void (boost::system::error_code)> callback_function =
670
+ callback;
671
+
662
672
boost::function<void ()> continuation = boost::bind (
663
- &async_connection<Tag,Handler>::write_vec_impl<ConstBufferSeq, Callback >
673
+ &async_connection<Tag,Handler>::template write_vec_impl<ConstBufferSeq, boost::function< void (boost::system::error_code)> >
664
674
,async_connection<Tag,Handler>::shared_from_this ()
665
- ,seq, callback , temporaries, buffers
675
+ ,seq, callback_function , temporaries, buffers
666
676
);
667
677
668
678
if (!headers_already_sent && !headers_in_progress) {
@@ -679,7 +689,7 @@ namespace boost { namespace network { namespace http {
679
689
,boost::bind (
680
690
&async_connection<Tag,Handler>::handle_write
681
691
,async_connection<Tag,Handler>::shared_from_this ()
682
- ,callback
692
+ ,callback_function
683
693
,temporaries
684
694
,buffers
685
695
,asio::placeholders::error
0 commit comments