From f7d477389645e01add789443619c313f672d7bda Mon Sep 17 00:00:00 2001 From: Thomas Gosteli Date: Wed, 21 Mar 2018 09:34:18 +0100 Subject: [PATCH] document that some headers can't be set by WithHeader --- httpclient.go | 1 + httpclient_test.go | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/httpclient.go b/httpclient.go index f34c2be..8f66c3b 100644 --- a/httpclient.go +++ b/httpclient.go @@ -191,6 +191,7 @@ func WithContentType(ct string) Opt { } // WithHeader is a client option for setting custom http header(s) for each request +// Content-Type and Accept headers will always be overwritten by the clients ContentType setting func WithHeader(header http.Header) Opt { return func(c *Client) error { c.header = header diff --git a/httpclient_test.go b/httpclient_test.go index 8ec7629..813b638 100644 --- a/httpclient_test.go +++ b/httpclient_test.go @@ -118,7 +118,9 @@ func TestClient(t *testing.T) { req, err := c.NewRequest(http.MethodGet, "/test", nil) assert.Nil(t, err) - assert.Equal(t, req.Header, customHeader) + assert.Equal(t, req.Header["X-Requested-By"], []string{"test"}) + assert.Contains(t, req.Header, "Content-Type") + assert.Contains(t, req.Header, "Accept") }) t.Run("new client valid baseurl valid HTTP client", func(t *testing.T) {