W3cubDocs

/WordPress

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

Match redirect behavior 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.

Parameters

$locationstringrequired
URL to redirect to.
$headersarrayrequired
Headers for the redirect.
$datastring|arrayrequired
Body to send with the request.
$optionsarrayrequired
Redirect request options.
$originalWpOrgRequestsResponserequired
Response object.

Source

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

Changelog

Version Description
4.6.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_http/browser_redirect_compatibility