#24987 closed enhancement (fixed)
HTTP requests should handle passing Cookies on redirects
Reported by: | dd32 | Owned by: | dd32 |
---|---|---|---|
Milestone: | 3.7 | Priority: | normal |
Severity: | normal | Version: | 3.7 |
Component: | HTTP API | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
A follow on from #21182
When a request is made a remote location which redirects, any set cookies are not used in the following requests.
This causes plugin developers to have to handle redirections manually, passing the cookies between calls.
In addition, any cookies used within the request, should be returned in the 'cookies' array. This is a slight behaviour change, Previously it'd only include cookies that were set, not those that were passed to it. I don't see this causing any significant change to existing code.
Working code and unit tests are available on #21182 and will be committed shortly.
Attachments (2)
Change History (8)
#1
@
11 years ago
- Keywords has-patch commit added
- Owner set to dd32
- Status changed from new to accepted
#3
@
11 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
If the $response
we get back before doing the cookie addition is a WP_Error, then we get a "cannot use object of type WP_Error as array" error in line 202: $cookies_set = wp_list_pluck( $response['cookies'], 'name' );
, which results in a fatal error.
The forthcoming patch avoids the fatal by returning before adding the cookies if we've gotten a WP_Error back. Props @nacin.
Requires 21182.3.diff includes Changes and Unit Tests