| 647 | } |
| 648 | |
| 649 | void HTTPRequest::ChunkEnd() { |
| 650 | assert(startedChunkTransfer && !replySent); |
| 651 | |
| 652 | HTTPEvent* ev = new HTTPEvent(eventBase, true, NULL, |
| 653 | std::bind(evhttp_send_reply_end, req)); |
| 654 | |
| 655 | ev->trigger(0); |
| 656 | |
| 657 | // If HTTPRequest is destroyed before connection is closed, evhttp seems to get messed up. |
| 658 | // We wait here for connection close before returning back to the handler, where HTTPRequest will be reclaimed. |
| 659 | waitClientClose(); |
| 660 | |
| 661 | replySent = true; |
| 662 | // `WriteReply` sets req to 0 to prevent req from being freed. But this is not enough in the case of long-polling. |
| 663 | // Something is still freed to early. |
| 664 | // req = 0; |
| 665 | } |
| 666 | |
| 667 | void HTTPRequest::Chunk(const std::string& chunk) { |
| 668 | assert(!replySent); |
no test coverage detected