Skip to content

Commit 2f4e634

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

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
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_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)