Skip to content

Commit c0e214b

Browse files
omalashenkodeanberris
authored andcommitted
Fixed async_connection::write() SFINAE-isation
Overloaded function selection based on ConstBufferSeq::value_type. http_server_async_less_copy test fixed accordingly.
1 parent a912ab9 commit c0e214b

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

boost/network/protocol/http/server/async_connection.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,15 @@ namespace boost { namespace network { namespace http {
216216
}
217217

218218
template <class Range, class Callback>
219-
typename disable_if<is_base_of<asio::const_buffer, Range>, void>::type
219+
typename disable_if<is_base_of<asio::const_buffer, typename Range::value_type>, void>::type
220220
write(Range const & range, Callback const & callback) {
221221
lock_guard lock(headers_mutex);
222222
if (error_encountered) boost::throw_exception(boost::system::system_error(*error_encountered));
223223
write_impl(boost::make_iterator_range(range), callback);
224224
}
225225

226226
template <class ConstBufferSeq, class Callback>
227-
typename enable_if<is_base_of<asio::const_buffer, ConstBufferSeq>, void>::type
227+
typename enable_if<is_base_of<asio::const_buffer, typename ConstBufferSeq::value_type>, void>::type
228228
write(ConstBufferSeq const & seq, Callback const & callback)
229229
{
230230
write_vec_impl(seq, callback, shared_array_list(), shared_buffers());

libs/network/test/http/server_async_less_copy.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
#define BOOST_TEST_MODULE HTTP Asynchronous Server Tests
88

9+
#include <vector>
10+
911
#include <boost/config/warning_disable.hpp>
1012
#include <boost/network/include/http/server.hpp>
1113
#include <boost/network/utils/thread_pool.hpp>
@@ -51,9 +53,9 @@ struct async_hello_world {
5153
static char const * hello_world = "Hello, World!";
5254
connection->set_status(server::connection::ok);
5355
connection->set_headers(boost::make_iterator_range(headers, headers+3));
54-
connection->write(
55-
boost::asio::const_buffers_1(hello_world, 13)
56-
, boost::bind(&async_hello_world::error, this, _1));
56+
std::vector<boost::asio::const_buffer> iovec;
57+
iovec.push_back(boost::asio::const_buffer(hello_world, 13));
58+
connection->write(iovec, boost::bind(&async_hello_world::error, this, _1));
5759
}
5860
}
5961

0 commit comments

Comments
 (0)