After pull #4288, RPC messages indicating errors have a Content-Length unrelated to their actual contents, rendering bitcoin-cli and curl unable to decode the reply.
This patch sets the Content-Length field based on the actual content returned.
Additionally, pull #4288 clobbered the error descriptions provided in ErrorReply, which bitcoin-cli relies upon; this patch moves #4288's new http-error descriptions to an HTTPError method, allowing HTTPReply to pass content on unchanged.
Example of the bug:
bitcoin-cli sendrawtransaction 00 error: couldn't parse reply from server
Before #4288 / restored by this patch:
bitcoin-cli sendrawtransaction 00 error: {"code":-22,"message":"TX decode failed"}