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

Commita912ab9

Browse files
committed
Supporting Custom Ports in Host Header for Requests
This commit addresses mikhailberis/cpp-netlib#25 which puts the port aspart of the Host header in HTTP requests.
1 parentec4689a commita912ab9

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

‎boost/network/protocol/http/algorithms/linearize.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include<boost/network/protocol/http/request_concept.hpp>
1414
#include<boost/network/constants.hpp>
1515
#include<boost/concept/requires.hpp>
16+
#include<boost/optional.hpp>
1617
#include<boost/range/algorithm/copy.hpp>
1718

1819
namespaceboost {namespacenetwork {namespacehttp {
@@ -95,6 +96,12 @@ namespace boost { namespace network { namespace http {
9596
*oi =consts::colon_char();
9697
*oi =consts::space_char();
9798
boost::copy(request.host(), oi);
99+
boost::optional<boost::uint16_t> port_ =port(request);
100+
if (port_) {
101+
string_type port_str = boost::lexical_cast<string_type>(*port_);
102+
*oi =consts::colon_char();
103+
boost::copy(port_str, oi);
104+
}
98105
boost::copy(crlf, oi);
99106
boost::copy(accept, oi);
100107
*oi =consts::colon_char();

‎boost/network/protocol/http/message/wrappers/port.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
// (See accompanying file LICENSE_1_0.txt or copy at
88
// http://www.boost.org/LICENSE_1_0.txt)
99

10+
#include<boost/optional.hpp>
11+
1012
namespaceboost {namespacenetwork {namespacehttp {
1113

1214
template<classTag>
@@ -26,6 +28,10 @@ namespace boost { namespace network { namespace http {
2628
operatorport_type() {
2729
return message_.port();
2830
}
31+
32+
operator boost::optional<boost::uint16_t> () {
33+
returnport(message_.uri());
34+
}
2935
};
3036

3137
}// namespace impl

‎boost/network/protocol/http/message/wrappers/uri.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
// (See accompanying file LICENSE_1_0.txt or copy at
88
// http://www.boost.org/LICENSE_1_0.txt)
99

10+
#include<boost/network/uri/http/uri.hpp>
11+
1012
namespaceboost {namespacenetwork {namespacehttp {
1113

1214
template<classTag>
@@ -22,6 +24,9 @@ namespace boost { namespace network { namespace http {
2224
operatorstring_type() {
2325
return message_.uri().raw();
2426
}
27+
operator boost::network::uri::basic_uri<tags::http_default_8bit_tcp_resolve> () {
28+
return message_.uri();
29+
}
2530
};
2631
}
2732

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp