Subject: Combining multiple message-header fields

From: "Bjoern Hoehrmann" <[email-masked]>
Date: Sat, 15 Jul 2000 17:44:40 +0200

Hi,

RFC2616 says:

| 4.2 Message Headers
| [...]
|    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.

I'm building a HTTP UserAgent with PHP and now i'm dealing with this multiple
message-header fields. If my UserAgent receives such multiple fields, should
it combine these fields into one or should it keep the multiple fields and
send it to the server (if present in a request)? The problem behind this is
the storage of this header fields. Currently i have an associative array that
does something like

Accept => array(text/html, image/*)

if there was

Accept: text/html
Accept: image/*

but when someone wants the value of Accept i only want to return a string and
therefor i only return the first value i.e. text/html which does not meet
someones expactation.

I appreciate your help,
regards,
  Björn Höhrmann
--
"Jede  Straße,  der  man konsequent \ und du wirst ihn in Gänze sehen.
bis zu ihrem Ende folgt,  führt un- ) Stehst Du auf seinem Gipfel wird
weigerlich  ins  Nichts.   Erklimme ( er  für  Dich  unsichtbar" -- P.
einen  Berg nur ein kleines  Stück, \ Irulan <http://bjoernsworld.de/>

---

From: "Life is hard, and then you die" <[email-masked]>
Date: Sat, 15 Jul 2000 12:39:55 -0700

On Sat, Jul 15, 2000 at 05:44:40PM +0200, Bjoern Hoehrmann wrote:
[snip]
> the storage of this header fields. Currently i have an associative array that
[snip]

Combining multiple header fields works just fine, with one exception: the
Set-Cookie header field. Some browsers don't handle multiple cookies in a
Set-Cookie header field (i.e. they require a separate header field for each
cookie to be set). Furthermore, because a number of sites use broken cookies
which contain commas in the value, parsing a combined Set-Cookie header field
can be a little tricky.

  Cheers,

  Ronald

---

From: "Bjoern Hoehrmann" <[email-masked]>
Date: Sat, 15 Jul 2000 21:55:51 +0200

* Life is hard, and then you die <[email-masked]> wrote:
| Combining multiple header fields works just fine, with one exception: the
| Set-Cookie header field. Some browsers don't handle multiple cookies in a
| Set-Cookie header field (i.e. they require a separate header field for each
| cookie to be set).

Ok, good to know, thanks.

regards,
  Björn Höhrmann