Skip to content

Commit b519d0c

Browse files
committed
Change the async_write from template to function
1 parent 38f4ee0 commit b519d0c

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Release/include/cpprest/details/http_server_asio.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ class hostport_listener;
5858
class connection
5959
{
6060
private:
61+
typedef void (connection::*ResponseFuncPtr) (const http_response &response, const boost::system::error_code& ec);
62+
6163
std::unique_ptr<boost::asio::ip::tcp::socket> m_socket;
6264
boost::asio::streambuf m_request_buf;
6365
boost::asio::streambuf m_response_buf;
@@ -108,8 +110,7 @@ class connection
108110
void handle_chunked_body(const boost::system::error_code& ec, int toWrite);
109111
void dispatch_request_to_listener();
110112
void do_response(bool bad_request);
111-
template <typename ClassFuncPtr>
112-
void async_write(ClassFuncPtr &&connection_func_ptr, const http_response &response);
113+
void async_write(ResponseFuncPtr response_func_ptr, const http_response &response);
113114
template <typename CompletionCondition, typename Handler>
114115
void async_read(CompletionCondition &&condition, Handler &&read_handler);
115116
void async_read_until();

Release/src/http/listener/http_server_asio.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -481,21 +481,20 @@ void connection::handle_body(const boost::system::error_code& ec)
481481
}
482482
}
483483

484-
template <typename ClassFuncPtr>
485-
void connection::async_write(ClassFuncPtr &&connection_func_ptr, const http_response &response)
484+
void connection::async_write(ResponseFuncPtr response_func_ptr, const http_response &response)
486485
{
487486
if (m_ssl_stream)
488487
{
489488
boost::asio::async_write(*m_ssl_stream, m_response_buf, [=] (const boost::system::error_code& ec, std::size_t)
490489
{
491-
(this->*connection_func_ptr)(response, ec);
490+
(this->*response_func_ptr)(response, ec);
492491
});
493492
}
494493
else
495494
{
496495
boost::asio::async_write(*m_socket, m_response_buf, [=] (const boost::system::error_code& ec, std::size_t)
497496
{
498-
(this->*connection_func_ptr)(response, ec);
497+
(this->*response_func_ptr)(response, ec);
499498
});
500499
}
501500
}

0 commit comments

Comments
 (0)