WP_Http::browser_redirect_compatibility() WordPress Method

The WP_Http::browser_redirect_compatibility() function is used to check for browser compatibility with the HTTP redirects sent by the server. This function is used by the WordPress HTTP class to ensure that the HTTP redirects are compatible with the user's browser.

WP_Http::browser_redirect_compatibility( string $location, array $headers, string|array $data, array $options, Requests_Response $original ) #

Match redirect behaviour to browser handling.


Description

Changes 302 redirects from POST to GET to match browser handling. Per RFC 7231, user agents can deviate from the strict reading of the specification for compatibility purposes.


Top ↑

Parameters

$location

(string)(Required)URL to redirect to.

$headers

(array)(Required)Headers for the redirect.

$data

(string|array)(Required)Body to send with the request.

$options

(array)(Required)Redirect request options.

$original

(Requests_Response)(Required)Response object.


Top ↑

Source

File: wp-includes/class-wp-http.php

	public static function browser_redirect_compatibility( $location, $headers, $data, &$options, $original ) {
		// Browser compatibility.
		if ( 302 === $original->status_code ) {
			$options['type'] = Requests::GET;
		}
	}

Top ↑

Changelog

Changelog
VersionDescription
4.6.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.