basho/webmachine — pull request #62 by beerriot (2012-03-02 13:39:07+00:00)
Title: Do not exit when mochiweb_socket:send returns an error

This patch fixes issue #59. Instead of exiting `normal` when `mochiweb_socket:send/2` does not return `ok`, this patch:

1. For non-streamed responses, simply returns success.
2. For streamed responses, halts further production of the stream, and returns the number of bytes sent so far.

The assumption is that an error from `mochiweb_socket:send/2` means that there was something wrong with the socket, not with our resource, and that that error will still be there when/if mochiweb attempts to read from it for the next request in the pipeline. Returning success here allows the request to be recorded by the access logger.