mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
HTTP API: Revert changeset [52244].
Reverting Requests 2.0.0 changes and moving to WordPress 6.0 cycle. Why? The namespace and file case renaming revealed 2 issues in Core's upgrader process. See https://core.trac.wordpress.org/ticket/54504#comment:22 for more information. Follow-up to [52327]. See #54562, #54504. git-svn-id: https://develop.svn.wordpress.org/trunk@52328 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -7,11 +7,11 @@
|
||||
* @since 2.7.0
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'WpOrg\Requests\Autoload' ) ) {
|
||||
require ABSPATH . WPINC . '/Requests/Autoload.php';
|
||||
if ( ! class_exists( 'Requests' ) ) {
|
||||
require ABSPATH . WPINC . '/class-requests.php';
|
||||
|
||||
WpOrg\Requests\Autoload::register();
|
||||
WpOrg\Requests\Requests::set_certificate_path( ABSPATH . WPINC . '/certificates/ca-bundle.crt' );
|
||||
Requests::register_autoloader();
|
||||
Requests::set_certificate_path( ABSPATH . WPINC . '/certificates/ca-bundle.crt' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -274,14 +274,14 @@ class WP_Http {
|
||||
if ( empty( $url ) || empty( $parsed_url['scheme'] ) ) {
|
||||
$response = new WP_Error( 'http_request_failed', __( 'A valid URL was not provided.' ) );
|
||||
/** This action is documented in wp-includes/class-wp-http.php */
|
||||
do_action( 'http_api_debug', $response, 'response', 'WpOrg\Requests\Requests', $parsed_args, $url );
|
||||
do_action( 'http_api_debug', $response, 'response', 'Requests', $parsed_args, $url );
|
||||
return $response;
|
||||
}
|
||||
|
||||
if ( $this->block_request( $url ) ) {
|
||||
$response = new WP_Error( 'http_request_not_executed', __( 'User has blocked requests through HTTP.' ) );
|
||||
/** This action is documented in wp-includes/class-wp-http.php */
|
||||
do_action( 'http_api_debug', $response, 'response', 'WpOrg\Requests\Requests', $parsed_args, $url );
|
||||
do_action( 'http_api_debug', $response, 'response', 'Requests', $parsed_args, $url );
|
||||
return $response;
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ class WP_Http {
|
||||
if ( ! wp_is_writable( dirname( $parsed_args['filename'] ) ) ) {
|
||||
$response = new WP_Error( 'http_request_failed', __( 'Destination directory for file streaming does not exist or is not writable.' ) );
|
||||
/** This action is documented in wp-includes/class-wp-http.php */
|
||||
do_action( 'http_api_debug', $response, 'response', 'WpOrg\Requests\Requests', $parsed_args, $url );
|
||||
do_action( 'http_api_debug', $response, 'response', 'Requests', $parsed_args, $url );
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -346,7 +346,7 @@ class WP_Http {
|
||||
$options['max_bytes'] = $parsed_args['limit_response_size'];
|
||||
}
|
||||
|
||||
// If we've got cookies, use and convert them to WpOrg\Requests\Cookie.
|
||||
// If we've got cookies, use and convert them to Requests_Cookie.
|
||||
if ( ! empty( $parsed_args['cookies'] ) ) {
|
||||
$options['cookies'] = WP_Http::normalize_cookies( $parsed_args['cookies'] );
|
||||
}
|
||||
@@ -378,7 +378,7 @@ class WP_Http {
|
||||
// Check for proxies.
|
||||
$proxy = new WP_HTTP_Proxy();
|
||||
if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) {
|
||||
$options['proxy'] = new WpOrg\Requests\Proxy\HTTP( $proxy->host() . ':' . $proxy->port() );
|
||||
$options['proxy'] = new Requests_Proxy_HTTP( $proxy->host() . ':' . $proxy->port() );
|
||||
|
||||
if ( $proxy->use_authentication() ) {
|
||||
$options['proxy']->use_authentication = true;
|
||||
@@ -391,7 +391,7 @@ class WP_Http {
|
||||
mbstring_binary_safe_encoding();
|
||||
|
||||
try {
|
||||
$requests_response = WpOrg\Requests\Requests::request( $url, $headers, $data, $type, $options );
|
||||
$requests_response = Requests::request( $url, $headers, $data, $type, $options );
|
||||
|
||||
// Convert the response into an array.
|
||||
$http_response = new WP_HTTP_Requests_Response( $requests_response, $parsed_args['filename'] );
|
||||
@@ -399,7 +399,7 @@ class WP_Http {
|
||||
|
||||
// Add the original object to the array.
|
||||
$response['http_response'] = $http_response;
|
||||
} catch ( WpOrg\Requests\Exception $e ) {
|
||||
} catch ( Requests_Exception $e ) {
|
||||
$response = new WP_Error( 'http_request_failed', $e->getMessage() );
|
||||
}
|
||||
|
||||
@@ -416,7 +416,7 @@ class WP_Http {
|
||||
* @param array $parsed_args HTTP request arguments.
|
||||
* @param string $url The request URL.
|
||||
*/
|
||||
do_action( 'http_api_debug', $response, 'response', 'WpOrg\Requests\Requests', $parsed_args, $url );
|
||||
do_action( 'http_api_debug', $response, 'response', 'Requests', $parsed_args, $url );
|
||||
if ( is_wp_error( $response ) ) {
|
||||
return $response;
|
||||
}
|
||||
@@ -452,10 +452,10 @@ class WP_Http {
|
||||
* @since 4.6.0
|
||||
*
|
||||
* @param array $cookies Array of cookies to send with the request.
|
||||
* @return WpOrg\Requests\Cookie\Jar Cookie holder object.
|
||||
* @return Requests_Cookie_Jar Cookie holder object.
|
||||
*/
|
||||
public static function normalize_cookies( $cookies ) {
|
||||
$cookie_jar = new WpOrg\Requests\Cookie\Jar();
|
||||
$cookie_jar = new Requests_Cookie_Jar();
|
||||
|
||||
foreach ( $cookies as $name => $value ) {
|
||||
if ( $value instanceof WP_Http_Cookie ) {
|
||||
@@ -465,9 +465,9 @@ class WP_Http {
|
||||
return null !== $attr;
|
||||
}
|
||||
);
|
||||
$cookie_jar[ $value->name ] = new WpOrg\Requests\Cookie( $value->name, $value->value, $attributes, array( 'host-only' => $value->host_only ) );
|
||||
$cookie_jar[ $value->name ] = new Requests_Cookie( $value->name, $value->value, $attributes, array( 'host-only' => $value->host_only ) );
|
||||
} elseif ( is_scalar( $value ) ) {
|
||||
$cookie_jar[ $name ] = new WpOrg\Requests\Cookie( $name, (string) $value );
|
||||
$cookie_jar[ $name ] = new Requests_Cookie( $name, $value );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -483,16 +483,16 @@ class WP_Http {
|
||||
*
|
||||
* @since 4.6.0
|
||||
*
|
||||
* @param string $location URL to redirect to.
|
||||
* @param array $headers Headers for the redirect.
|
||||
* @param string|array $data Body to send with the request.
|
||||
* @param array $options Redirect request options.
|
||||
* @param WpOrg\Requests\Response $original Response object.
|
||||
* @param string $location URL to redirect to.
|
||||
* @param array $headers Headers for the redirect.
|
||||
* @param string|array $data Body to send with the request.
|
||||
* @param array $options Redirect request options.
|
||||
* @param Requests_Response $original Response object.
|
||||
*/
|
||||
public static function browser_redirect_compatibility( $location, $headers, $data, &$options, $original ) {
|
||||
// Browser compatibility.
|
||||
if ( 302 === $original->status_code ) {
|
||||
$options['type'] = WpOrg\Requests\Requests::GET;
|
||||
$options['type'] = Requests::GET;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -501,12 +501,12 @@ class WP_Http {
|
||||
*
|
||||
* @since 4.7.5
|
||||
*
|
||||
* @throws WpOrg\Requests\Exception On unsuccessful URL validation.
|
||||
* @throws Requests_Exception On unsuccessful URL validation.
|
||||
* @param string $location URL to redirect to.
|
||||
*/
|
||||
public static function validate_redirects( $location ) {
|
||||
if ( ! wp_http_validate_url( $location ) ) {
|
||||
throw new WpOrg\Requests\Exception( __( 'A valid URL was not provided.' ), 'wp_http.redirect_failed_validation' );
|
||||
throw new Requests_Exception( __( 'A valid URL was not provided.' ), 'wp_http.redirect_failed_validation' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user