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. */
| 523 | * this cannot be done from worker threads. |
| 524 | */ |
| 525 | void HTTPRequest::WriteReply(int nStatus, const std::string& strReply) |
| 526 | { |
| 527 | assert(!replySent && req); |
| 528 | // Send event to main http thread to send reply message |
| 529 | struct evbuffer* evb = evhttp_request_get_output_buffer(req); |
| 530 | assert(evb); |
| 531 | evbuffer_add(evb, strReply.data(), strReply.size()); |
| 532 | HTTPEvent* ev = new HTTPEvent(eventBase, true, |
| 533 | boost::bind(evhttp_send_reply, req, nStatus, (const char*)NULL, (struct evbuffer *)NULL)); |
| 534 | ev->trigger(0); |
| 535 | replySent = true; |
| 536 | req = 0; // transferred back to main thread |
| 537 | } |
| 538 | |
| 539 | CService HTTPRequest::GetPeer() |
| 540 | { |
no test coverage detected