Skip to content

Commit

Permalink
Merge pull request #217 from ivanilves/trace-on-4xx-5xx-code
Browse files Browse the repository at this point in the history
chore(auth): Do not skip tracing/header printing on 5xx/4xx code
  • Loading branch information
vonrabbe authored Feb 6, 2020
2 parents d6888d7 + fda7542 commit d901dcd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions api/v1/registry/client/request/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ func perform(url, auth, mode string, trace bool) (resp *http.Response, err error
if err != nil {
return nil, err
}
if resp.StatusCode != 200 && resp.StatusCode != 404 {
return resp, errors.New("Bad response status: " + resp.Status + " >> " + url)
}

if trace {
fmt.Printf("%s|@URL: %s\n", rid, url)
for k, v := range req.Header {
fmt.Printf("%s|@REQ-HEADER: %-40s = %s\n", rid, k, v)
}
for k, v := range resp.Header {
fmt.Printf("%s|@HEADER: %-40s = %s\n", rid, k, v)
fmt.Printf("%s|@RESP-HEADER: %-40s = %s\n", rid, k, v)
}
fmt.Printf("%s|--- BODY BEGIN ---\n", rid)
for _, line := range strings.Split(getResponseBody(resp), "\n") {
Expand All @@ -70,6 +70,10 @@ func perform(url, auth, mode string, trace bool) (resp *http.Response, err error
fmt.Printf("%s|--- BODY END ---\n", rid)
}

if resp.StatusCode != 200 && resp.StatusCode != 404 {
return resp, errors.New("Bad response status: " + resp.Status + " >> " + url)
}

return resp, nil
}

Expand Down

0 comments on commit d901dcd

Please sign in to comment.