HTTP API: Add browser compatibility hook for 3xx redirects.
WordPress erroneously follows browser-style behaviour with 3xx redirects, where a POST to 302 becomes a GET. Requests instead follows the specification and keeps the same method. Requests also exposes a hook to allow changing the behaviour. [37428] used the wrong method of adding this hook, now corrected. See #33055. git-svn-id: https://develop.svn.wordpress.org/trunk@37429 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
9074e9f93b
commit
8d0c62ad50
|
@ -304,8 +304,12 @@ class WP_Http {
|
||||||
'timeout' => $r['timeout'],
|
'timeout' => $r['timeout'],
|
||||||
'useragent' => $r['user-agent'],
|
'useragent' => $r['user-agent'],
|
||||||
'blocking' => $r['blocking'],
|
'blocking' => $r['blocking'],
|
||||||
|
'hooks' => new Requests_Hooks(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Ensure redirects follow browser behaviour.
|
||||||
|
$options['hooks']->register( 'requests.before_redirect', array( get_class(), 'browser_redirect_compatibility' ) );
|
||||||
|
|
||||||
if ( $r['stream'] ) {
|
if ( $r['stream'] ) {
|
||||||
$options['filename'] = $r['filename'];
|
$options['filename'] = $r['filename'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,7 +207,6 @@ add_filter( 'xmlrpc_pingback_error', 'xmlrpc_pingback_error' );
|
||||||
add_filter( 'title_save_pre', 'trim' );
|
add_filter( 'title_save_pre', 'trim' );
|
||||||
|
|
||||||
add_filter( 'http_request_host_is_external', 'allowed_http_request_hosts', 10, 2 );
|
add_filter( 'http_request_host_is_external', 'allowed_http_request_hosts', 10, 2 );
|
||||||
add_action( 'requests-requests.before_redirect', array( 'WP_Http', 'browser_redirect_compatibility' ), 10, 5 );
|
|
||||||
|
|
||||||
// REST API filters.
|
// REST API filters.
|
||||||
add_action( 'xmlrpc_rsd_apis', 'rest_output_rsd' );
|
add_action( 'xmlrpc_rsd_apis', 'rest_output_rsd' );
|
||||||
|
|
Loading…
Reference in New Issue