From 76a62e52ae0d9a2b6f36294e6561a81bedae3dfb Mon Sep 17 00:00:00 2001 From: Fish-pro Date: Fri, 10 Feb 2023 14:01:48 +0800 Subject: [PATCH] Use http constants instead of string Signed-off-by: Fish-pro --- cmd/ctr/commands/pprof/pprof.go | 2 +- remotes/docker/auth/fetch.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/ctr/commands/pprof/pprof.go b/cmd/ctr/commands/pprof/pprof.go index 4dae72613..fad812986 100644 --- a/cmd/ctr/commands/pprof/pprof.go +++ b/cmd/ctr/commands/pprof/pprof.go @@ -225,7 +225,7 @@ func httpGetRequest(client *http.Client, request string) (io.ReadCloser, error) if err != nil { return nil, err } - if resp.StatusCode != 200 { + if resp.StatusCode != http.StatusOK { resp.Body.Close() return nil, fmt.Errorf("http get failed with status: %s", resp.Status) } diff --git a/remotes/docker/auth/fetch.go b/remotes/docker/auth/fetch.go index 43c67f680..64c6a38f9 100644 --- a/remotes/docker/auth/fetch.go +++ b/remotes/docker/auth/fetch.go @@ -114,7 +114,7 @@ func FetchTokenWithOAuth(ctx context.Context, client *http.Client, headers http. form.Set("access_type", "offline") } - req, err := http.NewRequestWithContext(ctx, "POST", to.Realm, strings.NewReader(form.Encode())) + req, err := http.NewRequestWithContext(ctx, http.MethodPost, to.Realm, strings.NewReader(form.Encode())) if err != nil { return nil, err } @@ -161,7 +161,7 @@ type FetchTokenResponse struct { // FetchToken fetches a token using a GET request func FetchToken(ctx context.Context, client *http.Client, headers http.Header, to TokenOptions) (*FetchTokenResponse, error) { - req, err := http.NewRequestWithContext(ctx, "GET", to.Realm, nil) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, to.Realm, nil) if err != nil { return nil, err }