Opened 15 years ago
Closed 15 years ago
#11555 closed defect (bug) (fixed)
HTTP Streams transport returns duplicate headers during redirections
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.0 | Priority: | normal |
Severity: | normal | Version: | 2.9 |
Component: | HTTP API | Keywords: | has-patch |
Focuses: | Cc: |
Description
When using the Streams transport, The Headers returned become doubled up if a redirection takes place.
Example in the case of 3 redirects:
<?php $url = "http://localhost/redirect/?rt=2"; $html = wp_remote_get($url, array('max-redirects' => 7)); echo '<pre>'; var_dump($html); ?> array(4) { ["headers"]=> array(7) { ["date"]=> array(2) { [0]=> array(2) { [0]=> string(29) "Tue, 22 Dec 2009 06:56:52 GMT" [1]=> string(29) "Tue, 22 Dec 2009 06:56:52 GMT" } [1]=> string(29) "Tue, 22 Dec 2009 06:56:52 GMT" } ["server"]=> array(2) { [0]=> array(2) { [0]=> string(31) "Apache/2.2.14 (Win32) PHP/5.3.0" [1]=> string(31) "Apache/2.2.14 (Win32) PHP/5.3.0" } [1]=> string(31) "Apache/2.2.14 (Win32) PHP/5.3.0" } ["x-powered-by"]=> array(2) { [0]=> array(2) { [0]=> string(9) "PHP/5.3.0" [1]=> string(9) "PHP/5.3.0" } [1]=> string(9) "PHP/5.3.0" } ["location"]=> array(2) { [0]=> string(19) "/redirect/?rt=2&r=1" [1]=> string(19) "/redirect/?rt=2&r=2" } ["content-length"]=> array(2) { [0]=> array(2) { [0]=> string(2) "15" [1]=> string(2) "15" } [1]=> string(2) "24" } ["connection"]=> array(2) { [0]=> array(2) { [0]=> string(5) "close" [1]=> string(5) "close" } [1]=> string(5) "close" } ["content-type"]=> array(2) { [0]=> array(2) { [0]=> string(9) "text/html" [1]=> string(9) "text/html" } [1]=> string(9) "text/html" } } ["body"]=> string(24) "Redirect 2 of 2 is FINAL" ["response"]=> array(2) { ["code"]=> string(3) "200" ["message"]=> string(2) "OK" } ["cookies"]=> array(0) { } }
The first Array element of the response for each header is the previous redirects header... I'll work on a patch in a moment.
Attachments (1)
Change History (6)
#3
@
15 years ago
- Keywords reporter-feedback added
dd32 can you just attach your redirect testing script so that other devs can easier test this?
#4
@
15 years ago
- Keywords reporter-feedback removed
You can test this against anything which redirects. that being said, A test redirector is at http://tools.dd32.id.au/redirect/
Note: See
TracTickets for help on using
tickets.
Attahed patch takes an array such as this, returned from $wraper_data, and pulls out the final group of headers:
From:
To:
Whilst the headers of the in-between requests can be useful sometimes, The WordPress HTTP API currently doesnt expose them, so discarding these is "OK"