WP_HTTP: Cookies: When following redirects, include the request cookies in the redirected requests. Fixes #24987
Built from https://develop.svn.wordpress.org/trunk@25046 git-svn-id: http://core.svn.wordpress.org/trunk@25033 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
29739b2508
commit
ef3b20c949
|
@ -195,7 +195,19 @@ class WP_Http {
|
|||
$r['headers']['Content-Length'] = strlen( $r['body'] );
|
||||
}
|
||||
|
||||
return $this->_dispatch_request($url, $r);
|
||||
$response = $this->_dispatch_request($url, $r);
|
||||
|
||||
// Append cookies that were used in this request to the response
|
||||
if ( ! empty( $r['cookies'] ) ) {
|
||||
$cookies_set = wp_list_pluck( $response['cookies'], 'name' );
|
||||
foreach ( $r['cookies'] as $cookie ) {
|
||||
if ( ! in_array( $cookie->name, $cookies_set ) && $cookie->test( $url ) ) {
|
||||
$response['cookies'][] = $cookie;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -639,6 +651,14 @@ class WP_Http {
|
|||
$args['method'] = 'GET';
|
||||
}
|
||||
|
||||
// Include valid cookies in the redirect process
|
||||
if ( ! empty( $response['cookies'] ) ) {
|
||||
foreach ( $response['cookies'] as $cookie ) {
|
||||
if ( $cookie->test( $redirect_location ) )
|
||||
$args['cookies'][] = $cookie;
|
||||
}
|
||||
}
|
||||
|
||||
return wp_remote_request( $redirect_location, $args );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue