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 into account the `function` flag of the incoming message 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.