Skip to content

Commit 01a2c29

Browse files
authored
Merge pull request #873 from evoskuil/master
Adapt to network mime_type::application_octet[_stream] rename.
2 parents 9b35b48 + 654b3fe commit 01a2c29

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

include/bitcoin/node/protocols/protocol_html.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ class BCN_API protocol_html
5252
const network::http::method::get& request) NOEXCEPT override;
5353

5454
/// Senders.
55-
void send_file(const network::http::string_request& request,
55+
void send_file(const network::http::request& request,
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: 7 additions & 6 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;
@@ -72,15 +72,15 @@ void protocol_html::handle_receive_get(const code& ec,
7272
return;
7373
}
7474

75-
const auto default_type = mime_type::application_octet;
75+
const auto default_type = mime_type::application_octet_stream;
7676
send_file(*request, std::move(file), file_mime_type(path, default_type));
7777
}
7878

7979
// Senders.
8080
// ----------------------------------------------------------------------------
8181

82-
void protocol_html::send_file(const string_request& request,
83-
file&& file, mime_type type) NOEXCEPT
82+
void protocol_html::send_file(const request& request, file&& file,
83+
mime_type type) NOEXCEPT
8484
{
8585
BC_ASSERT_MSG(stranded(), "strand");
8686
BC_ASSERT_MSG(file.is_open(), "sending closed file handle");
@@ -98,13 +98,14 @@ void protocol_html::send_file(const string_request& request,
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)