Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions boost/network/protocol/http/server/async_connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,11 +462,18 @@ struct async_connection
enum state_t { method, uri, version, headers };

void start() {
typename ostringstream<Tag>::type ip_stream;
ip_stream << socket_.remote_endpoint().address().to_string() << ':'
<< socket_.remote_endpoint().port();
request_.source = ip_stream.str();
read_more(method);
boost::system::error_code ec;
auto remote_endpoint = socket_.remote_endpoint(ec);

if (ec) {
error_encountered = in_place<boost::system::system_error>(ec);
} else {
typename ostringstream<Tag>::type ip_stream;
ip_stream << remote_endpoint.address().to_string() << ':'
<< remote_endpoint.port();
request_.source = ip_stream.str();
read_more(method);
}
}

void read_more(state_t state) {
Expand Down
15 changes: 12 additions & 3 deletions boost/network/protocol/stream_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,21 @@ struct stream_handler {
}
}

tcp_socket::endpoint_type remote_endpoint() const {
tcp_socket::endpoint_type remote_endpoint(boost::system::error_code& ec) const {
if (ssl_enabled) {
return ssl_sock_->next_layer().remote_endpoint();
return ssl_sock_->next_layer().remote_endpoint(ec);
} else {
return tcp_sock_->remote_endpoint();
return tcp_sock_->remote_endpoint(ec);
}
}

tcp_socket::endpoint_type remote_endpoint() const {
boost::system::error_code ec;
tcp_socket::endpoint_type r = remote_endpoint(ec);
if (ec) {
boost::asio::detail::throw_error(ec, "remote_endpoint");
}
return r;
}

void shutdown(boost::asio::socket_base::shutdown_type st,
Expand Down