Closure sent to main thread to request a reply to be sent to * a HTTP request. * Replies must be sent in the main loop in the main http thread, * this cannot be done from worker threads. */
| 599 | * this cannot be done from worker threads. |
| 600 | */ |
| 601 | void HTTPRequest::WriteReply(int nStatus, const std::string& strReply) |
| 602 | { |
| 603 | assert(!replySent && req); |
| 604 | // Send event to main http thread to send reply message |
| 605 | struct evbuffer* evb = evhttp_request_get_output_buffer(req); |
| 606 | assert(evb); |
| 607 | evbuffer_add(evb, strReply.data(), strReply.size()); |
| 608 | HTTPEvent* ev = new HTTPEvent(eventBase, true, |
| 609 | std::bind(evhttp_send_reply, req, nStatus, (const char*)NULL, (struct evbuffer *)NULL)); |
| 610 | ev->trigger(0); |
| 611 | replySent = true; |
| 612 | req = 0; // transferred back to main thread |
| 613 | } |
| 614 | |
| 615 | CService HTTPRequest::GetPeer() |
| 616 | { |
no test coverage detected