Make WordPress Core

Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#9037 closed defect (bug) (fixed)

HTTP API only allows one instance of a particular header

Reported by: beaulebens's profile beaulebens Owned by:
Milestone: 2.8 Priority: normal
Severity: normal Version:
Component: HTTP API Keywords:
Focuses: Cc:

Description

When the WP_Http() API parses a response from a request that it's made, it parses the headers into an associative array, using the header name as the key.

This is normally fine, but there are some headers (e.g. Set-Cookie) which are allowed to be set more than once. In this case, each instance of the header encountered overwrites the previous one, so that the headers you get back end up only showing the last instance of that header.

This patch allows it to handle multiple appearances of each header, converting that array entry into an array of values for that header if there are more than one seen.

e.g.

Array
(
    [set-cookie] => Array
        (
            [0] => SC=RV=99624-702292-13606-284784-700373-665639-658887-358464-700145; expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/finance; domain=.google.com
            [1] => PREF=ID=d8c01cf54463c45f:TM=1233709869:LM=1233709870:S=lh-ZtpcyTb0Cu1Vh; expires=Fri, 04-Feb-2011 01:11:10 GMT; path=/; domain=.google.com
        )

    [date] => Wed, 04 Feb 2009 01:11:10 GMT
    [expires] => Wed, 04 Feb 2009 01:11:10 GMT
    [cache-control] => private, max-age=0
    [content-type] => text/html; charset=ISO-8859-1
    [server] => SFE/0.8
    [connection] => Close
)

Attachments (1)

http-duplicate-headers.diff (641 bytes) - added by beaulebens 16 years ago.
Allows multiple appearances of headers in response handling.

Download all attachments as: .zip

Change History (4)

@beaulebens
16 years ago

Allows multiple appearances of headers in response handling.

#1 @beaulebens
16 years ago

  • Summary changed from HTTP API only allows once instance of a particular header to HTTP API only allows one instance of a particular header

#2 @ryan
16 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [10512]) Cookie support for HTTP API. Props beaulebens. fixes #9049 #9037 #8727

#3 @ryan
16 years ago

Argh, accidentally included bits for #9048 in there. Ignore them.

Note: See TracTickets for help on using tickets.