Skip to content

Commit 8c7943b

Browse files
authored
Merge pull request #881 from evoskuil/master
Add send_buffer sender to protocol_html.
2 parents 1778557 + c37ac50 commit 8c7943b

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

include/bitcoin/node/protocols/protocol_html.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ class BCN_API protocol_html
7171
virtual void send_span(const network::http::request& request,
7272
network::http::span_body::value_type&& span,
7373
network::http::mime_type type) NOEXCEPT;
74+
virtual void send_buffer(const network::http::request& request,
75+
network::http::buffer_body::value_type&& buffer,
76+
network::http::mime_type type) NOEXCEPT;
7477

7578
/// Utilities.
7679
bool is_allowed_origin(const network::http::fields& fields,

src/protocols/protocol_html.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,18 @@ void protocol_html::send_span(const request& request,
223223
SEND(std::move(response), handle_complete, _1, error::success);
224224
}
225225

226+
void protocol_html::send_buffer(const request& request,
227+
buffer_body::value_type&& buffer, mime_type type) NOEXCEPT
228+
{
229+
BC_ASSERT(stranded());
230+
response response{ status::ok, request.version() };
231+
add_common_headers(response, request);
232+
response.set(field::content_type, from_mime_type(type));
233+
response.body() = std::move(buffer);
234+
response.prepare_payload();
235+
SEND(std::move(response), handle_complete, _1, error::success);
236+
}
237+
226238
// Utilities.
227239
// ----------------------------------------------------------------------------
228240

0 commit comments

Comments
 (0)