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,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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue