From 666a8fb0a4d7316e71375b6adeeba3c4b0ce67c7 Mon Sep 17 00:00:00 2001 From: Ivan Ilves Date: Tue, 4 Feb 2020 10:15:16 +0100 Subject: [PATCH 1/2] chore(auth): Do not skip tracing/header printing on 5xx/4xx code --- api/v1/registry/client/request/request.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/api/v1/registry/client/request/request.go b/api/v1/registry/client/request/request.go index b59f0d0..4f7af35 100644 --- a/api/v1/registry/client/request/request.go +++ b/api/v1/registry/client/request/request.go @@ -54,9 +54,6 @@ 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) @@ -70,6 +67,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 } From fda754266e6deb51d737303a438c8a0d0a41a563 Mon Sep 17 00:00:00 2001 From: Ivan Ilves Date: Thu, 6 Feb 2020 16:15:44 +0100 Subject: [PATCH 2/2] feat(client): Trace request headers as well as response headers --- api/v1/registry/client/request/request.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/v1/registry/client/request/request.go b/api/v1/registry/client/request/request.go index 4f7af35..af4c7fd 100644 --- a/api/v1/registry/client/request/request.go +++ b/api/v1/registry/client/request/request.go @@ -57,8 +57,11 @@ func perform(url, auth, mode string, trace bool) (resp *http.Response, err error 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") {