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

Method ReadBody

src/httpserver.cpp:493–511  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

491}
492
493std::string HTTPRequest::ReadBody()
494{
495 struct evbuffer* buf = evhttp_request_get_input_buffer(req);
496 if (!buf)
497 return "";
498 size_t size = evbuffer_get_length(buf);
499 /** Trivial implementation: if this is ever a performance bottleneck,
500 * internal copying can be avoided in multi-segment buffers by using
501 * evbuffer_peek and an awkward loop. Though in that case, it'd be even
502 * better to not copy into an intermediate string but use a stream
503 * abstraction to consume the evbuffer on the fly in the parsing algorithm.
504 */
505 const char* data = (const char*)evbuffer_pullup(buf, size);
506 if (!data) // returns NULL in case of empty buffer
507 return "";
508 std::string rv(data, size);
509 evbuffer_drain(buf, size);
510 return rv;
511}
512
513void HTTPRequest::WriteHeader(const std::string& hdr, const std::string& value)
514{

Callers 2

rest_getutxosFunction · 0.80
HTTPReq_JSONRPCFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected