| 616 | } |
| 617 | |
| 618 | std::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 | |
| 638 | bool HTTPRequest::ReplySent() { |
| 639 | return replySent; |
no outgoing calls
no test coverage detected