Description
As discussed in #3554, attempting to access known header keys directly from the maps provided by:
using the provided constant, canonicalized header keys does not work when the external header keys do not exactly match the case of our provided constants.
There are two solutions to this problem:
Solution 1:
- canonicalize all header keys every time a
HookDelivery
struct is returned (here, here, and here, plus six more locations).
Solution 2:
- add two new helper methods that would provide a Header.Get-like experience for
HookRequest
andHookResponse
such that the header key lookup is totally case insensitive (both for the search strings and for the contents of the map), like this:
// GetHeader gets the value associated with the given key (ignoring key case).
func (h *HookRequest) GetHeader(key string) string {
...
}
// GetHeader gets the value associated with the given key (ignoring key case).
func (h *HookResponse) GetHeader(key string) string {
...
}
I'm open to either solution. @sparshev - do you have a preference?
This would be a great PR for any new contributor to this repo or a new Go developer.
All contributions are greatly appreciated!
Feel free to volunteer for any issue and the issue can be assigned to you so that others don't attempt to duplicate the work.
Also feel free to perform a code review on any PR that has the label "NeedsReview" - we appreciate those contributions too!
We have a REVIEWERS
file that you could add your username to if you are willing to be contacted when reviews are needed.
Please check out our CONTRIBUTING.md guide to get started. (In particular, please remember to go generate ./...
and don't use force-push to your PRs.)
Thank you!