Background: Working on a Widget that uses a remote API using
wp_remote_post to log into the service, once logged in storing the cookies received for the second request to query data with
Problem: The cookies from the first request are stored in the response as WP_Http_Cookie objects and their values are run through
urldecode as seen in class-http.php. One of the cookies has an original value of
l0xl4+7abTT2St+1UVA thanks to the
urldecode this value becomes
l0xl4 7abTT2St 1UVA in the WP_Http_Cookie object and therefore is not the same. This makes the cookie object unusable as is for the second request.
Workaround: I came up with a nasty little workaround for this problem:
// Replace space with + from cookie value // because WP_Http_Cookie does urldecode( value ) $response['cookies']->value = str_replace(' ', '+', $response['cookies']->value); // Set cookies for the second request $this->cookies = $response['cookies'];
Question: Does anyone know why there is an
urldecode instead of a filter in WP_Http_Cookie? Should I file a trac issue?