Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit16cf093

Browse files
committed
Provide source port as part of the request
1 parentd51d6e4 commit16cf093

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

‎boost/network/protocol/http/impl/request.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ namespace http {
157157
typedef vector_type headers_container_type;
158158
typedef boost::uint16_t port_type;
159159
mutable string_type source;
160+
mutable port_type source_port;
160161
mutable string_type method;
161162
mutable string_type destination;
162163
mutable boost::uint8_t http_version_major;
@@ -168,6 +169,7 @@ namespace http {
168169
using std::swap;
169170
swap(method, r.method);
170171
swap(source, r.source);
172+
swap(source_port, r.source_port);
171173
swap(destination, r.destination);
172174
swap(http_version_major, r.http_version_major);
173175
swap(http_version_minor, r.http_version_minor);

‎boost/network/protocol/http/server/sync_connection.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ namespace boost { namespace network { namespace http {
7979
voidhandle_read_headers(boost::system::error_codeconst &ec,size_t bytes_transferred) {
8080
if (!ec) {
8181
request_.source = socket_.remote_endpoint().address().to_string();
82+
request_.source_port = socket_.remote_endpoint().port();
8283
boost::tribool done;
8384
buffer_type::iterator new_start;
8485
tie(done,new_start) = parser_.parse_headers(request_, buffer_.data(), buffer_.data() + bytes_transferred);

‎libs/network/example/http/hello_world_server.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ struct hello_world {
2929
voidoperator() (server::requestconst &request,
3030
server::response &response) {
3131
server::string_type ip =source(request);
32+
unsignedint port = request.source_port;
3233
std::ostringstream data;
33-
data <<"Hello," << ip <<"!";
34+
data <<"Hello," << ip <<':' << port <<'!';
3435
response =server::response::stock_reply(
3536
server::response::ok, data.str());
3637
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp