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

Use set for sensitiveHeaders #802

Merged
merged 2 commits into from
Apr 2, 2024
Merged

Conversation

ribice
Copy link
Collaborator

@ribice ribice commented Mar 29, 2024

Replaced bool with empty struct to better represent a set, which is what SensitiveHeaders is.

func BenchmarkNewRequest(b *testing.B) {
	const payload = `{"test_data": true}`
	r := httptest.NewRequest("POST", "/test/?q=sentry", strings.NewReader(payload))
	r.Header.Add("Authorization", "Bearer 1234567890")
	r.Header.Add("Cookie", "foo=bar")
	r.Header.Add("X-Forwarded-For", "127.0.0.1")
	r.Header.Add("X-Real-Ip", "127.0.0.1")
	r.Header.Add("Some-Header", "some-header value")

	b.ReportAllocs()
	for i := 0; i < b.N; i++ {
		NewRequest(r)
	}
}

Before:

BenchmarkNewRequest-10    	 2724643	       430.9 ns/op	     504 B/op	       7 allocs/op

After:

BenchmarkNewRequest-10    	 2993946	       394.1 ns/op	     504 B/op	       7 allocs/op

#skip-changelog

@ribice ribice requested a review from cleptric March 29, 2024 23:59
Copy link

codecov bot commented Mar 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.14%. Comparing base (c10f51e) to head (fae152e).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #802      +/-   ##
==========================================
- Coverage   81.17%   81.14%   -0.04%     
==========================================
  Files          49       49              
  Lines        4127     4120       -7     
==========================================
- Hits         3350     3343       -7     
  Misses        635      635              
  Partials      142      142              

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

Copy link
Member

@cleptric cleptric left a comment

Choose a reason for hiding this comment

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

lgtm

@ribice ribice merged commit 271dc49 into master Apr 2, 2024
21 of 22 checks passed
@ribice ribice deleted the sensitive-headers-preallocate branch April 2, 2024 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants