#13513 closed defect (bug) (invalid)
Processing HTTP Headers violates RFC 2616 - same header-name with multiple fields and values not normalized
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.0 |
Component: | HTTP API | Keywords: | |
Focuses: | Cc: |
Description
Quote:
Multiple message-header fields with the same field-name MAY be present in a message if and only if the entire field-value for that header field is defined as a comma-separated list [i.e., #(values)]. It MUST be possible to combine the multiple header fields into one "field-name: field-value" pair, without changing the semantics of the message, by appending each subsequent field-value to the first, each separated by a comma. 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.
Summary:
- Multiple message-header fields with the same field-name MAY be present
- It MUST be possible to combine the multiple header fields into one "field-name: field-value" pair
Currently the code is creating an array instead of a comma separated list.
Attachments (6)
Change History (21)
#2
follow-up:
↓ 3
@
15 years ago
- Keywords needs-patch added; has-patch removed
- Milestone changed from 3.0 to Future Release
Can you post a reference for where the quote comes from?
Moving to Future Release pending patch.
#3
in reply to:
↑ 2
@
15 years ago
Replying to dd32:
Can you post a reference for where the quote comes from?
RFC 2616, 4.2 (Message Headers)
#4
@
15 years ago
- Version set to 3.0
A first patch. There is another issue regarding the response status code and message by injecting header not containing any colons. That is somehow already prevented by the "redirection" handling (which will only return the last status field and/or the injected one as I just see, need to update the patch).
I'll update the current patch to remove my handling of that again.
Additionally there is another issue with tolerant status line parsing we do not cover:
Clients SHOULD be tolerant in parsing the Status-Line [...]. In particular, they SHOULD accept any amount of SP or HT characters between fields, even though only a single SP is required.
Source: 19.3 Tolerant Applications / RFC 2616
We just do an explode on a single space.
#5
@
15 years ago
- Keywords has-patch tested added; needs-patch removed
Updated the patch according to my previous notes. Un-needed check for setting the status line has been removed again and the better status line parsing has been implemented according RFC instead.
I gave it a testrun on my testbed and it looks good from my side. I also tested the preg_split code on example data.
#6
@
15 years ago
- Milestone changed from Future Release to 3.1
- Status changed from new to accepted
Will handle this in 3.1
#8
follow-ups:
↓ 9
↓ 10
@
14 years ago
- Keywords close 2nd-opinion added
After reading the spec closer, I see no need to change anything here.
Specifically, the RFC quoted is specifying that the fields MAY be combined into a comma separated list(and that servers MUST present multiple headers in a form in which combining to a comma separated list will retain the original meaning), It is not dictating how a client must present the data given to a client (Excluding proxies, who must present the headers in the order given to them, and must not combine them, so as to preserve the meaning behind the message)
Note, That this is different from unfolding where a header is split over multiple lines, and must be re-combined before presenting the field to clients.
#10
in reply to:
↑ 8
@
14 years ago
- Keywords close removed
Replying to dd32:
After reading the spec closer, I see no need to change anything here.
Specifically, the RFC quoted is specifying that the fields MAY be combined into a comma separated list(and that servers MUST present multiple headers in a form in which combining to a comma separated list will retain the original meaning), It is not dictating how a client must present the data given to a client (Excluding proxies, who must present the headers in the order given to them, and must not combine them, so as to preserve the meaning behind the message)
I see and I can follow that argumentation. What has been represented as a comma separated list within headers is then represented as an array list in our PHP. I'm fine with that approach, I think that's correct after re-reading.
However that does as well mean that multiple header-fields with the same header-name are only correct, if the specification allows a list.
Regardless of that fact, I'm against being too strict here and compare against a list (for the moment) which header-names have such a property (list values) specified or not.
Instead I suggest for those headers that provide multiple header-values to check those if they already contain commas per one array entry and normalize all array entries to values w/o commas so the values are normalized.
@
14 years ago
process multiple headers the same as a comma sperated list of values and handle such a list as an array in PHP
#11
@
14 years ago
And there was that minor patch left which is not in scope, but well, too less to open a ticket on it's own I suppose.
#13
@
14 years ago
- Milestone Future Release deleted
- Resolution set to invalid
- Status changed from accepted to closed
no, Headers should be given as the server has presented it. If it offers a comma separated list, thats what should be passed back to the client.
As for the "minor patch", I prefer the more readable current form (Which is used in all the transports)
Closing as invalid due to not needing to implement it. (Please don't re-open this for the purpose of discussing the minor patch, as the purpose of the ticket is invalid anyway)
Related: #9395