Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions boost/network/protocol/http/impl/request.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ namespace http {
typedef vector_type headers_container_type;
typedef boost::uint16_t port_type;
mutable string_type source;
mutable port_type source_port;
mutable string_type method;
mutable string_type destination;
mutable boost::uint8_t http_version_major;
Expand All @@ -168,6 +169,7 @@ namespace http {
using std::swap;
swap(method, r.method);
swap(source, r.source);
swap(source_port, r.source_port);
swap(destination, r.destination);
swap(http_version_major, r.http_version_major);
swap(http_version_minor, r.http_version_minor);
Expand Down
1 change: 1 addition & 0 deletions boost/network/protocol/http/server/sync_connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ namespace boost { namespace network { namespace http {
void handle_read_headers(boost::system::error_code const &ec, size_t bytes_transferred) {
if (!ec) {
request_.source = socket_.remote_endpoint().address().to_string();
request_.source_port = socket_.remote_endpoint().port();
boost::tribool done;
buffer_type::iterator new_start;
tie(done,new_start) = parser_.parse_headers(request_, buffer_.data(), buffer_.data() + bytes_transferred);
Expand Down
3 changes: 2 additions & 1 deletion libs/network/example/http/hello_world_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ struct hello_world {
void operator() (server::request const &request,
server::response &response) {
server::string_type ip = source(request);
unsigned int port = request.source_port;
std::ostringstream data;
data << "Hello, " << ip << "!";
data << "Hello, " << ip << ':' << port << '!';
response = server::response::stock_reply(
server::response::ok, data.str());
}
Expand Down