From dee1d583a71645d540f87f87ac93ebb9c8a788a5 Mon Sep 17 00:00:00 2001 From: Ryan McCue Date: Fri, 13 May 2016 05:11:27 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@37429 git-svn-id: http://core.svn.wordpress.org/trunk@37395 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-http.php | 4 ++++ wp-includes/default-filters.php | 3 +-- wp-includes/version.php | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/wp-includes/class-http.php b/wp-includes/class-http.php index 30c3dc9ca1..7511c100ed 100644 --- a/wp-includes/class-http.php +++ b/wp-includes/class-http.php @@ -304,8 +304,12 @@ class WP_Http { 'timeout' => $r['timeout'], 'useragent' => $r['user-agent'], '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'] ) { $options['filename'] = $r['filename']; } diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index c866c3732d..f7bfeb52fb 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -206,8 +206,7 @@ add_filter( 'pingback_ping_source_uri', 'pingback_ping_source_uri' ); add_filter( 'xmlrpc_pingback_error', 'xmlrpc_pingback_error' ); add_filter( 'title_save_pre', 'trim' ); -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 ); +add_filter( 'http_request_host_is_external', 'allowed_http_request_hosts', 10, 2 ); // REST API filters. add_action( 'xmlrpc_rsd_apis', 'rest_output_rsd' ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 5498dded3b..3fb973936d 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.6-alpha-37428'; +$wp_version = '4.6-alpha-37429'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.