@@ -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