Skip to content

Commit 654b3fe

Browse files
committed
Adapt to network use/convention of fields vs. string params.
1 parent 760331f commit 654b3fe

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

include/bitcoin/node/protocols/protocol_html.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class BCN_API protocol_html
5656
network::http::file&& file, network::http::mime_type type) NOEXCEPT;
5757

5858
/// Utilities.
59-
bool is_allowed_origin(const std::string& origin,
59+
bool is_allowed_origin(const network::http::fields& fields,
6060
size_t version) const NOEXCEPT;
6161
std::filesystem::path to_local_path(
6262
const std::string& target = "/") const NOEXCEPT;

src/protocols/protocol_explore.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ void protocol_explore::handle_receive_get(const code& ec,
4444
return;
4545

4646
// Enforce http origin policy (requires configured hosts).
47-
if (!is_allowed_origin((*request)[field::origin], request->version()))
47+
if (!is_allowed_origin(*request, request->version()))
4848
{
4949
send_forbidden(*request);
5050
return;
5151
}
5252

5353
// Enforce http host header (if any hosts are configured).
54-
if (!is_allowed_host((*request)[field::host], request->version()))
54+
if (!is_allowed_host(*request, request->version()))
5555
{
5656
send_bad_host(*request);
5757
return;

src/protocols/protocol_html.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ void protocol_html::handle_receive_get(const code& ec,
4343
return;
4444

4545
// Enforce http origin policy (requires configured hosts).
46-
if (!is_allowed_origin((*request)[field::origin], request->version()))
46+
if (!is_allowed_origin(*request, request->version()))
4747
{
4848
send_forbidden(*request);
4949
return;
5050
}
5151

5252
// Enforce http host header (if any hosts are configured).
53-
if (!is_allowed_host((*request)[field::host], request->version()))
53+
if (!is_allowed_host(*request, request->version()))
5454
{
5555
send_bad_host(*request);
5656
return;
@@ -98,13 +98,14 @@ void protocol_html::send_file(const request& request, file&& file,
9898
// Utilities.
9999
// ----------------------------------------------------------------------------
100100

101-
bool protocol_html::is_allowed_origin(const std::string& origin,
101+
bool protocol_html::is_allowed_origin(const fields& fields,
102102
size_t version) const NOEXCEPT
103103
{
104104
BC_ASSERT_MSG(stranded(), "strand");
105105

106106
// Allow same-origin and no-origin requests.
107107
// Origin header field is not available until http 1.1.
108+
const auto origin = fields[field::origin];
108109
if (origin.empty() || version < version_1_1)
109110
return true;
110111

0 commit comments

Comments
 (0)