Fix error handling in HttpProtocol

Since we added support for multiple protocols in actions, there has been a regression on protocol-level error handling. Instead of replying with the error message, we were actually closing the connection.

This fix takes the `function` flag into account to know whether we need to reply or not:
* function call => reply;
* function response, don't. 

It also comes with a bunch of tests to ensure this doesn't happen again.