Merge pull request #182 from fd0/handle-non-json-response

Only try to parse JSON documents
This commit is contained in:
xenolf 2016-04-05 22:22:36 +02:00
commit 157111fd1d

View file

@ -52,11 +52,15 @@ func (c challengeError) Error() string {
func handleHTTPError(resp *http.Response) error { func handleHTTPError(resp *http.Response) error {
var errorDetail RemoteError var errorDetail RemoteError
// try to decode the content as JSON
if resp.Header.Get("Content-Type") == "application/json" {
decoder := json.NewDecoder(resp.Body) decoder := json.NewDecoder(resp.Body)
err := decoder.Decode(&errorDetail) err := decoder.Decode(&errorDetail)
if err != nil { if err != nil {
return err return err
} }
}
errorDetail.StatusCode = resp.StatusCode errorDetail.StatusCode = resp.StatusCode