iderikon/swarm — pull request #1 by shindo (2014-12-22 19:28:06+00:00)
Title: send_reply() with status code reworked.

Now send_reply(int code) manually constructs http_response and
calls send_reply(http_response) method.

Previously send_reply(int code) method called send_error() method,
which defers close() method call.

send_reply() methods should send response to the client and stop request
processing as soon as posible.
This may be done by calling send_headers() and close() methods of the
underlying reply stream.

close() method sets special flag 'm_close_invoked' that stops handler's
methods invocation and defers close_impl() method call that actually
closes connection with the client (or reuses the existing one to process
next request).

Thus, send_reply() methods must not defer close() method call.

By now send_error() method is used internally when request handler
is not yet constructed (handers parsing failed, invalid URL, missing handler)
and close() method's call delay works fine.