Skip to content

Commit

Permalink
Merge pull request #211 from germanhs/master
Browse files Browse the repository at this point in the history
fix(#210): Provide a method to return all headers (not only first header) of a given key
  • Loading branch information
casualjim committed Aug 26, 2021
2 parents 872b746 + 4444a78 commit d555223
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions client/opentracing_test.go
Expand Up @@ -29,6 +29,9 @@ func (r tres) Message() string {
func (r tres) GetHeader(_ string) string {
return "the header"
}
func (r tres) GetHeaders(_ string) []string {
return []string{"the headers", "the headers2"}
}
func (r tres) Body() io.ReadCloser {
return ioutil.NopCloser(bytes.NewBufferString("the content"))
}
Expand Down
4 changes: 4 additions & 0 deletions client/response.go
Expand Up @@ -39,6 +39,10 @@ func (r response) GetHeader(name string) string {
return r.resp.Header.Get(name)
}

func (r response) GetHeaders(name string) []string {
return r.resp.Header.Values(name)
}

func (r response) Body() io.ReadCloser {
return r.resp.Body
}
1 change: 1 addition & 0 deletions client/response_test.go
Expand Up @@ -37,5 +37,6 @@ func TestResponse(t *testing.T) {
assert.EqualValues(t, under.StatusCode, resp.Code())
assert.Equal(t, under.Status, resp.Message())
assert.Equal(t, "blah blah", resp.GetHeader("blah"))
assert.Equal(t, []string{"blah blah"}, resp.GetHeaders("blah"))
assert.Equal(t, under.Body, resp.Body())
}
1 change: 1 addition & 0 deletions client_response.go
Expand Up @@ -27,6 +27,7 @@ type ClientResponse interface {
Code() int
Message() string
GetHeader(string) string
GetHeaders(string) []string
Body() io.ReadCloser
}

Expand Down
3 changes: 3 additions & 0 deletions client_response_test.go
Expand Up @@ -35,6 +35,9 @@ func (r response) Message() string {
func (r response) GetHeader(_ string) string {
return "the header"
}
func (r response) GetHeaders(_ string) []string {
return []string{"the headers", "the headers2"}
}
func (r response) Body() io.ReadCloser {
return ioutil.NopCloser(bytes.NewBufferString("the content"))
}
Expand Down

0 comments on commit d555223

Please sign in to comment.