Skip to content

Commit

Permalink
Fix: Go < 1.14 does not support http.Header.Values()
Browse files Browse the repository at this point in the history
  • Loading branch information
basvanbeek committed Sep 9, 2020
1 parent b7ed014 commit a4c38a5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions reporter/http/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func TestSpanCustomHeaders(t *testing.T) {
rep.Close()

for _, key := range []string{"Key1", "Key2"} {
if want, have := hc.headers.Values(key), haveHeaders.Values(key); !reflect.DeepEqual(want, have) {
if want, have := hc.headers[key], haveHeaders[key]; !reflect.DeepEqual(want, have) {
t.Errorf("header %s: want: %v, have: %v\n", key, want, have)
}
}
Expand All @@ -206,7 +206,7 @@ func TestSpanCustomHeaders(t *testing.T) {
func TestB3SamplingHeader(t *testing.T) {
serializer := reporter.JSONSerializer{}

var haveHeaders http.Header
var haveHeaders map[string][]string
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
haveHeaders = r.Header
}))
Expand All @@ -224,8 +224,8 @@ func TestB3SamplingHeader(t *testing.T) {
}
rep.Close()

if len(haveHeaders.Values("B3")) > 0 {
t.Errorf("Expected B3 header to not exist, got %v", haveHeaders.Values("B3"))
if len(haveHeaders["B3"]) > 0 {
t.Errorf("Expected B3 header to not exist, got %v", haveHeaders["B3"])
}

rep = zipkinhttp.NewReporter(
Expand All @@ -237,15 +237,15 @@ func TestB3SamplingHeader(t *testing.T) {
}
rep.Close()

if want, have := []string{"0"}, haveHeaders.Values("B3"); !reflect.DeepEqual(want, have) {
if want, have := []string{"0"}, haveHeaders["B3"]; !reflect.DeepEqual(want, have) {
t.Errorf("B3 header: want: %v, have %v", want, have)
}

}

type headerClient struct {
client http.Client
headers http.Header
headers map[string][]string
}

func (h headerClient) Do(req *http.Request) (*http.Response, error) {
Expand Down

0 comments on commit a4c38a5

Please sign in to comment.