Skip to content

Add case-instensitive GetHeader for HookRequest & HookResponse - #3556

Merged
gmlewis merged 3 commits into
google:masterfrom
sparshev:hookrequest_hookresponse_getheader
Apr 18, 2025
Merged

Add case-instensitive GetHeader for HookRequest & HookResponse#3556
gmlewis merged 3 commits into
google:masterfrom
sparshev:hookrequest_hookresponse_getheader

Conversation

@sparshev

Copy link
Copy Markdown
Contributor

Simple implementation for case-insensitive GetHeader. I thought about caching the keys, but it seems too complicated for now with additional not predictable memory consumption. Tests are included.

Fixes#3555

@gmlewisgmlewis changed the title Added case-instensitive GetHeader for HookRequest & HookResponseAdd case-instensitive GetHeader for HookRequest & HookResponseApr 18, 2025
@codecov

codecovBot commented Apr 18, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.24%. Comparing base (6a7684f) to head (2d0b5cc).
Report is 4 commits behind head on master.

Additional details and impacted files
@@ Coverage Diff @@## master #3556 +/- ##
=======================================
Coverage 91.23% 91.24% =======================================
Files 183 183 Lines 16053 16063 +10 =======================================
+ Hits 14646 14656 +10 
Misses 1231 1231 Partials 176 176 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gmlewisgmlewis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you add one more test case to each of your tests that covers lines 57 and 78, respectively, then the linter will be happy. 😄

@sparshev

Copy link
Copy Markdown
ContributorAuthor

Oh you right! Completely forgot about negative cases)

@gmlewisgmlewis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @sparshev!
LGTM.

Awaiting second LGTM+Approval from any other contributor to this repo before merging.

@stevehipwell - might you have time for a code review? Thank you!

@atilsensalduz

Copy link
Copy Markdown
Contributor

LGTM! Tiny nit: wdyt to abstract the common functionality into a shared helper function aims to reduce code duplication like below?

func getHeader(headers map[string]string, key string) string {
for k, v := range headers {
if strings.EqualFold(k, key) {
return v
}
}
return ""
}
func (r *HookRequest) GetHeader(key string) string {
return getHeader(r.Headers, key)
}
func (r *HookResponse) GetHeader(key string) string {
return getHeader(r.Headers, key)
}

@gmlewis

Copy link
Copy Markdown
Collaborator

Thank you, @atilsensalduz and @sparshev!
Merging after the tests all pass.

@gmlewis
gmlewis merged commit 5b75aa8 into google:masterApr 18, 2025
@sparshev
sparshev deleted the hookrequest_hookresponse_getheader branch April 18, 2025 21:06
jlaportebot added a commit to jlaportebot/go-github that referenced this pull request Jun 28, 2026
Sign up for freeto 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.

HookRequest.Headers and HookResponse.Headers maps need to be canonicalized

3 participants

@sparshev@atilsensalduz@gmlewis