MCPcopy Create free account
hub / github.com/ElementsProject/elements / ReadBody

Method ReadBody

src/httpserver.cpp:536–554  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

534}
535
536std::string HTTPRequest::ReadBody()
537{
538 struct evbuffer* buf = evhttp_request_get_input_buffer(req);
539 if (!buf)
540 return "";
541 size_t size = evbuffer_get_length(buf);
542 /** Trivial implementation: if this is ever a performance bottleneck,
543 * internal copying can be avoided in multi-segment buffers by using
544 * evbuffer_peek and an awkward loop. Though in that case, it'd be even
545 * better to not copy into an intermediate string but use a stream
546 * abstraction to consume the evbuffer on the fly in the parsing algorithm.
547 */
548 const char* data = (const char*)evbuffer_pullup(buf, size);
549 if (!data) // returns nullptr in case of empty buffer
550 return "";
551 std::string rv(data, size);
552 evbuffer_drain(buf, size);
553 return rv;
554}
555
556void HTTPRequest::WriteHeader(const std::string& hdr, const std::string& value)
557{

Callers 3

rest_getutxosFunction · 0.80
HTTPReq_JSONRPCFunction · 0.80
FUZZ_TARGETFunction · 0.80

Calls

no outgoing calls

Tested by 1

FUZZ_TARGETFunction · 0.64