diff --git a/config/http_config_test.go b/config/http_config_test.go index 5c2f15d2..02466c58 100644 --- a/config/http_config_test.go +++ b/config/http_config_test.go @@ -1680,3 +1680,33 @@ func TestHeaders(t *testing.T) { t.Fatalf("can't fetch URL: %v", err) } } + +func TestMultipleHeaders(t *testing.T) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + for k, v := range map[string][]string{ + "One": {"value1a", "value1b", "value1c"}, + "Two": {"value2a", "value2b", "value2c"}, + "Three": {"value3a", "value3b", "value3c"}, + } { + if !reflect.DeepEqual(r.Header.Values(k), v) { + t.Errorf("expected %v, got %v", v, r.Header.Values(k)) + } + } + w.WriteHeader(http.StatusNoContent) + })) + t.Cleanup(ts.Close) + + cfg, _, err := LoadHTTPConfigFile("testdata/http.conf.headers-multiple.good.yaml") + if err != nil { + t.Fatalf("Error loading HTTP client config: %v", err) + } + client, err := NewClientFromConfig(*cfg, "test") + if err != nil { + t.Fatalf("Error creating HTTP Client: %v", err) + } + + _, err = client.Get(ts.URL) + if err != nil { + t.Fatalf("can't fetch URL: %v", err) + } +} diff --git a/config/testdata/headers-file-a b/config/testdata/headers-file-a new file mode 100644 index 00000000..0d2a9cd4 --- /dev/null +++ b/config/testdata/headers-file-a @@ -0,0 +1,3 @@ +value3a + + diff --git a/config/testdata/headers-file-b b/config/testdata/headers-file-b new file mode 100644 index 00000000..c1240b44 --- /dev/null +++ b/config/testdata/headers-file-b @@ -0,0 +1 @@ +value3b diff --git a/config/testdata/headers-file-c b/config/testdata/headers-file-c new file mode 100644 index 00000000..264b69da --- /dev/null +++ b/config/testdata/headers-file-c @@ -0,0 +1 @@ +value3c