Closed grepsedawk closed 2 years ago
Putting this into draft because, while the tests pass, the private method is not exactly the same.
The private method previous was a "#includes?" via regex not ==
.
I'm going to run benchmarks and base my next approach based on those benchmarks.
Cool, asserting equality is faster and easier anyway Rack also doesn't seem to downcase the header ever, it boils down to calling: https://github.com/rack/rack/blob/a61c0b4fe7162df76cee617922c332b9b138d425/lib/rack/request.rb#L79 via https://github.com/rack/rack/blob/a61c0b4fe7162df76cee617922c332b9b138d425/lib/rack/request.rb#L643
Unless @env is auto-downcased.
The benchmarks are hard to read because you have both the match and mismatch tests in the same group. Can you separate out the two match runs from the mismatch runs so that the fastest
and nn x slower
stuff is meaningful?
Re downcasing, I know http header names are supposed to be case insensitive but I don't think I know that about the values.
The Rack tests only seem to test that x-forwarded-proto works correctly when it's all lowercase. The internet wisdom about configuring haproxy seems to have decided on using a lowercase https
but there's no reason for that to be necessarily true.
I think it's fine to remove the downcase.
It's more clear and way faster
Latest benchmark in commit message