Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(#210): Provide a method to return all headers (not only first header) of a given key #211

Merged
merged 7 commits into from Aug 26, 2021

Conversation

germanhs
Copy link
Contributor

@germanhs germanhs commented Aug 24, 2021

This is the fix for #210

It provides an additional method for the ClientResponse in response.go to retrieve all headers of a given key.

The current implementation only allows to retrieve the first header.

If you don't want to change the interface I would suggest to provide an extended version to which we can cast the Client Response.

… first header) for a given key in response.go

Signed-off-by: Marcel Oenning <marcel.oenning@sap.com>
Signed-off-by: Marcel Oenning <marcel.oenning@sap.com>
client_response.go Outdated Show resolved Hide resolved
Signed-off-by: Marcel Oenning <marcel.oenning@sap.com>
Signed-off-by: Marcel Oenning <marcel.oenning@sap.com>
@germanhs
Copy link
Contributor Author

germanhs commented Aug 25, 2021

In the test structures the GetHeaders function was missing. Can you rerun the workflow please? :)
Edit: I also added a small unit test.

moenning and others added 3 commits August 25, 2021 20:11
Signed-off-by: Marcel Oenning <marcel.oenning@sap.com>
Signed-off-by: Marcel Oenning <marcel.oenning@sap.com>
@youyuanwu
Copy link
Member

Should ClientResponse have a method to expose http.Response? If someone else want to handle special cases in the ClientResponse, the interface needs to be changed again.

@casualjim I will let you decide. This code is ready to merge.

@casualjim casualjim merged commit d555223 into go-openapi:master Aug 26, 2021
@leason00
Copy link

@germanhs
func (Header) Values ¶
added in go1.14
func (h Header) Values(key string) []string
Values returns all values associated with the given key. It is case insensitive; textproto.CanonicalMIMEHeaderKey is used to canonicalize the provided key. To use non-canonical keys, access the map directly. The returned slice is not a copy.

https://pkg.go.dev/net/http#Header

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants