diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2021-01-19 05:28:21 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2021-01-28 05:57:45 +0300 |
commit | 09f840543a841b6e9d8e8b17ded6b24e3fb22590 (patch) | |
tree | 4f71d2b02a26a2dd7585602c4362fb66cf1e9bca /test/acceptance | |
parent | b066cb1b76284c22732e3045d1d92a111a1a6123 (diff) |
Get headers in Go 1.13
Diffstat (limited to 'test/acceptance')
-rw-r--r-- | test/acceptance/serving_test.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/test/acceptance/serving_test.go b/test/acceptance/serving_test.go index 99afd25f..6afa9560 100644 --- a/test/acceptance/serving_test.go +++ b/test/acceptance/serving_test.go @@ -4,6 +4,7 @@ import ( "fmt" "io/ioutil" "net/http" + "net/textproto" "os" "path" "strings" @@ -678,9 +679,7 @@ func TestServerRepliesWithHeaders(t *testing.T) { require.Equal(t, http.StatusOK, rsp.StatusCode) for key, value := range test.expectedHeaders { - fmt.Printf("expected key: %q - value: %+v\n", key, value) - got := rsp.Header.Values(key) - fmt.Printf("got key: %q - value: %+v\n", key, got) + got := headerValues(rsp.Header, key) require.Equal(t, value, got) } } @@ -712,3 +711,11 @@ func TestServerRepliesWithHeaders(t *testing.T) { }) } } + +func headerValues(header http.Header, key string) []string { + h := textproto.MIMEHeader(header) + + // NOTE: cannot use header.Values() in Go 1.13 or lower, this is the implementation + // from Go 1.15 https://github.com/golang/go/blob/release-branch.go1.15/src/net/textproto/header.go#L46 + return h[textproto.CanonicalMIMEHeaderKey(key)] +} |