Branch: refs/heads/master
  Home:   https://github.com/btcsuite/btcrpcclient
  Commit: 2b780d16b042054d07aa322146194118fd7f7b81
      
https://github.com/btcsuite/btcrpcclient/commit/2b780d16b042054d07aa322146194118fd7f7b81
  Author: Dave Collins <da...@conformal.com>
  Date:   2016-09-16 (Fri, 16 Sep 2016)

  Changed paths:
    M infrastructure.go

  Log Message:
  -----------
  Improve HTTP error handling.

This modifies the code which handles failed server responses to attempt
to unmarshal the response bytes as a regular JSON-RPC response
regardless of the HTTP status code and, if that fails, return an error
that includes the status code as well as the raw response bytes.

This is being done because some JSON-RPC servers, such as Bitcoin Core,
don't follow the intended HTTP status code meanings.  For example, if
you request a block that doesn't exist, it returns a status code of 500
which is supposed to mean internal server error instead of a standard
200 status code (since the HTTP request itself was successful) along
with the JSON-RPC error response.

The result is that errors from Core will now show up as an actual
RPCError instead of an error with the raw JSON bytes.

This also has the benefit of returning the HTTP status code in the
error for real HTTP failure cases such as 401 authentication failures,
which previously would just be an empty error when used against Core
since it doesn't return the actual response along with the status code
as it should.


Reply via email to