forked from TrueCloudLab/lego
Merge pull request #182 from fd0/handle-non-json-response
Only try to parse JSON documents
This commit is contained in:
commit
157111fd1d
1 changed files with 8 additions and 4 deletions
|
@ -52,10 +52,14 @@ func (c challengeError) Error() string {
|
||||||
|
|
||||||
func handleHTTPError(resp *http.Response) error {
|
func handleHTTPError(resp *http.Response) error {
|
||||||
var errorDetail RemoteError
|
var errorDetail RemoteError
|
||||||
decoder := json.NewDecoder(resp.Body)
|
|
||||||
err := decoder.Decode(&errorDetail)
|
// try to decode the content as JSON
|
||||||
if err != nil {
|
if resp.Header.Get("Content-Type") == "application/json" {
|
||||||
return err
|
decoder := json.NewDecoder(resp.Body)
|
||||||
|
err := decoder.Decode(&errorDetail)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
errorDetail.StatusCode = resp.StatusCode
|
errorDetail.StatusCode = resp.StatusCode
|
||||||
|
|
Loading…
Reference in a new issue