only sort the headers by key not by value #44

Merged
merged 2 commits into from Nov 21, 2013

Projects

None yet

4 participants

@domruf
Contributor
domruf commented Sep 19, 2013

I have a application that offers different kinds of authentication methods (Basic and Negotiate).
The problem is that Firefox uses them in the order they are listed in the HTTP header.
waitress currently sorts the headers by key and value which because Firefox to use Basic instead of Negotiate because it starts with B.

@domruf domruf only sort the headers by key not by value
--HG--
extra : rebase_source : 28c8db5c527838341f125e10f8ec770352c92b75
b8d453d
@mmerickel
Member

Should the headers be sorted at all by waitress?

@domruf
Contributor
domruf commented Sep 19, 2013

I don't know if there are any cases where the key order matters.
I guess it is easier to read when debugging.

@agroszer
Contributor

Testing comes to mind, when output matters

@domruf
Contributor
domruf commented Sep 20, 2013

I found another place that manipulates the headers.
This time not only the order of the headers but the content.
In line 200 The headers get "capitalized".
But one of my clients seems to ignore Authenticate headers like 'Www-Authenticate' and only reads headers like 'WWW-Authenticate'

@domruf
Contributor
domruf commented Sep 20, 2013

OK, I found the according text in the RFC.

http://www.ietf.org/rfc/rfc2616.txt (4.2) says

"...The order in which header fields with the same field-name are received is therefore significant to the interpretation of the combined field value, and thus a proxy MUST NOT change the order of these field values when a message is forwarded..."

It also says

"Field names are case-insensitive"

So why would waitress capitalize the header names?

@mcdonc
Member
mcdonc commented Nov 21, 2013

For what it's worth, I think you've misinterpreted the RFC section you quote. The section you quote deals with headers that have the same name, not headers that have different names. Regarding headers that have different names the spec says " The order in which header fields with differing field names are received is not significant."

@mcdonc
Member
mcdonc commented Nov 21, 2013

Nope, nevermind, I misinterpreted your bug report and the test case you provided.

@mcdonc mcdonc merged commit e9ca506 into Pylons:master Nov 21, 2013
@mcdonc
Member
mcdonc commented Nov 21, 2013

Thank you, this has been merged to master.

@mcdonc
Member
mcdonc commented Nov 30, 2013

Waitress 0.8.8 is out with this fix.

@domruf
Contributor
domruf commented Dec 2, 2013

great thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment