MCPcopy Create free account
hub / github.com/LUX-Core/lux / ReadBody

Method ReadBody

src/httpserver.cpp:618–636  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

616}
617
618std::string HTTPRequest::ReadBody()
619{
620 struct evbuffer* buf = evhttp_request_get_input_buffer(req);
621 if (!buf)
622 return "";
623 size_t size = evbuffer_get_length(buf);
624 /** Trivial implementation: if this is ever a performance bottleneck,
625 * internal copying can be avoided in multi-segment buffers by using
626 * evbuffer_peek and an awkward loop. Though in that case, it'd be even
627 * better to not copy into an intermediate string but use a stream
628 * abstraction to consume the evbuffer on the fly in the parsing algorithm.
629 */
630 const char* data = (const char*)evbuffer_pullup(buf, size);
631 if (!data) // returns NULL in case of empty buffer
632 return "";
633 std::string rv(data, size);
634 evbuffer_drain(buf, size);
635 return rv;
636}
637
638bool HTTPRequest::ReplySent() {
639 return replySent;

Callers 2

rest_getutxosFunction · 0.80
HTTPReq_JSONRPCFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected