MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / ReadBody

Method ReadBody

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

Source from the content-addressed store, hash-verified

552}
553
554std::string HTTPRequest::ReadBody()
555{
556 struct evbuffer* buf = evhttp_request_get_input_buffer(req);
557 if (!buf)
558 return "";
559 size_t size = evbuffer_get_length(buf);
560 /** Trivial implementation: if this is ever a performance bottleneck,
561 * internal copying can be avoided in multi-segment buffers by using
562 * evbuffer_peek and an awkward loop. Though in that case, it'd be even
563 * better to not copy into an intermediate string but use a stream
564 * abstraction to consume the evbuffer on the fly in the parsing algorithm.
565 */
566 const char* data = (const char*)evbuffer_pullup(buf, size);
567 if (!data) // returns nullptr in case of empty buffer
568 return "";
569 std::string rv(data, size);
570 evbuffer_drain(buf, size);
571 return rv;
572}
573
574void HTTPRequest::WriteHeader(const std::string& hdr, const std::string& value)
575{

Callers 2

rest_getutxosFunction · 0.80
HTTPReq_JSONRPCFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected