Skip to content
This repository has been archived by the owner on Sep 28, 2021. It is now read-only.

Make request and response header names lower-case #96

Merged
merged 3 commits into from
May 13, 2016

Conversation

pettermahlen
Copy link
Member

This change introduces a Headers type so as to break backwards
compatibility and trigger compiler errors if the Request.headers()
or Response.headers() methods are called expecting a Map as the
return value.

Header names are lower-cased, to simplify case comparisons and be
compatible with HTTP/2. A part of the reasoning around making
this simplistic change is that lower-casing is very cheap for
a string that is already lower-case, and thus doing the lower-
casing always will only lead to a performance hit the first time
a header is processed. Headers that are propagated internally
will always be lower case when handled by downstream services.

This is an alternative solution to #93.

@pettermahlen
Copy link
Member Author

@rouzwawi @ccarpita @mattnworb @zalenski opinions?

.filter(HeadersValue::hasNonLowerCase)
.findAny()
.map(lowerCaseKeys(headers))
.orElse(headers);
Copy link
Member

@mattnworb mattnworb Apr 27, 2016

Choose a reason for hiding this comment

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

this stream operation seems confusing to me:

  1. it would seem to filter out any keys that are all lower-case
  2. and the map operation ignores the input (the s in s ->)

is the goal to avoid modifying the map in the happy case when the keys are already all lower case? since you have to iterate over all the keys anyway, it seems like it there wouldn't be any real work saved

Copy link
Member

Choose a reason for hiding this comment

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

I mean, I see in the tests that it works, it was just confusing as to how it works until I ran the tests manually to see 😄

@mattnworb
Copy link
Member

Overall seems sensible to me, although I don't have much of a dog in this fight 👍

@pettermahlen
Copy link
Member Author

The failed build appears to be due to a problem with codecov.io. They seem to be having problems at the moment, according to: http://status.codecov.io/, which says there are intermittent failures due to a systems upgrade since a couple of days.

@pettermahlen
Copy link
Member Author

@mattnworb thanks for the feedback, i've tried to clarify the implementation a bit - better?

@ccarpita
Copy link

I did happen to have a dog in this fight, and am pleased with the results :)

FWIW the updated lowercase-checking implementation seemed clear to me at first read.

@mattnworb
Copy link
Member

@pettermahlen 👍 on improved clarity!

This change introduces a Headers type so as to break backwards
compatibility and trigger compiler errors if the Request.headers()
or Response.headers() methods are called expecting a Map as the
return value.

Header names are lower-cased, to simplify case comparisons and be
compatible with HTTP/2. A part of the reasoning around making
this simplistic change is that lower-casing is very cheap for
a string that is already lower-case, and thus doing the lower-
casing always will only lead to a performance hit the first time
a header is processed. Headers that are propagated internally
will always be lower case when handled by downstream services.
@codecov-io
Copy link

Current coverage is 66.56%

Merging #96 into master will increase coverage by +0.24%

@@             master        #96   diff @@
==========================================
  Files           117        119     +2   
  Lines          2443       2461    +18   
  Methods           0          0          
  Messages          0          0          
  Branches        207        212     +5   
==========================================
+ Hits           1620       1638    +18   
  Misses          780        780          
  Partials         43         43          

Powered by Codecov. Last updated by 6d3ca0e

@pettermahlen pettermahlen merged commit d4b62a6 into spotify:master May 13, 2016
@pettermahlen pettermahlen deleted the case-insensitive-headers branch May 13, 2016 09:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants