Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaime Martinez <jmartinez@gitlab.com>2021-01-19 05:28:21 +0300
committerJaime Martinez <jmartinez@gitlab.com>2021-01-28 05:57:45 +0300
commit09f840543a841b6e9d8e8b17ded6b24e3fb22590 (patch)
tree4f71d2b02a26a2dd7585602c4362fb66cf1e9bca
parentb066cb1b76284c22732e3045d1d92a111a1a6123 (diff)
Get headers in Go 1.13
-rw-r--r--test/acceptance/serving_test.go13
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)]
+}