Changeset 52328 for trunk/src/wp-includes/class-wp-http.php
- Timestamp:
- 12/06/2021 09:29:00 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-http.php
r52327 r52328 8 8 */ 9 9 10 if ( ! class_exists( ' WpOrg\Requests\Autoload' ) ) {11 require ABSPATH . WPINC . '/ Requests/Autoload.php';12 13 WpOrg\Requests\Autoload::register();14 WpOrg\Requests\Requests::set_certificate_path( ABSPATH . WPINC . '/certificates/ca-bundle.crt' );10 if ( ! class_exists( 'Requests' ) ) { 11 require ABSPATH . WPINC . '/class-requests.php'; 12 13 Requests::register_autoloader(); 14 Requests::set_certificate_path( ABSPATH . WPINC . '/certificates/ca-bundle.crt' ); 15 15 } 16 16 … … 275 275 $response = new WP_Error( 'http_request_failed', __( 'A valid URL was not provided.' ) ); 276 276 /** This action is documented in wp-includes/class-wp-http.php */ 277 do_action( 'http_api_debug', $response, 'response', ' WpOrg\Requests\Requests', $parsed_args, $url );277 do_action( 'http_api_debug', $response, 'response', 'Requests', $parsed_args, $url ); 278 278 return $response; 279 279 } … … 282 282 $response = new WP_Error( 'http_request_not_executed', __( 'User has blocked requests through HTTP.' ) ); 283 283 /** This action is documented in wp-includes/class-wp-http.php */ 284 do_action( 'http_api_debug', $response, 'response', ' WpOrg\Requests\Requests', $parsed_args, $url );284 do_action( 'http_api_debug', $response, 'response', 'Requests', $parsed_args, $url ); 285 285 return $response; 286 286 } … … 299 299 $response = new WP_Error( 'http_request_failed', __( 'Destination directory for file streaming does not exist or is not writable.' ) ); 300 300 /** This action is documented in wp-includes/class-wp-http.php */ 301 do_action( 'http_api_debug', $response, 'response', ' WpOrg\Requests\Requests', $parsed_args, $url );301 do_action( 'http_api_debug', $response, 'response', 'Requests', $parsed_args, $url ); 302 302 return $response; 303 303 } … … 347 347 } 348 348 349 // If we've got cookies, use and convert them to WpOrg\Requests\Cookie.349 // If we've got cookies, use and convert them to Requests_Cookie. 350 350 if ( ! empty( $parsed_args['cookies'] ) ) { 351 351 $options['cookies'] = WP_Http::normalize_cookies( $parsed_args['cookies'] ); … … 379 379 $proxy = new WP_HTTP_Proxy(); 380 380 if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) { 381 $options['proxy'] = new WpOrg\Requests\Proxy\HTTP( $proxy->host() . ':' . $proxy->port() );381 $options['proxy'] = new Requests_Proxy_HTTP( $proxy->host() . ':' . $proxy->port() ); 382 382 383 383 if ( $proxy->use_authentication() ) { … … 392 392 393 393 try { 394 $requests_response = WpOrg\Requests\Requests::request( $url, $headers, $data, $type, $options );394 $requests_response = Requests::request( $url, $headers, $data, $type, $options ); 395 395 396 396 // Convert the response into an array. … … 400 400 // Add the original object to the array. 401 401 $response['http_response'] = $http_response; 402 } catch ( WpOrg\Requests\Exception $e ) {402 } catch ( Requests_Exception $e ) { 403 403 $response = new WP_Error( 'http_request_failed', $e->getMessage() ); 404 404 } … … 417 417 * @param string $url The request URL. 418 418 */ 419 do_action( 'http_api_debug', $response, 'response', ' WpOrg\Requests\Requests', $parsed_args, $url );419 do_action( 'http_api_debug', $response, 'response', 'Requests', $parsed_args, $url ); 420 420 if ( is_wp_error( $response ) ) { 421 421 return $response; … … 453 453 * 454 454 * @param array $cookies Array of cookies to send with the request. 455 * @return WpOrg\Requests\Cookie\Jar Cookie holder object.455 * @return Requests_Cookie_Jar Cookie holder object. 456 456 */ 457 457 public static function normalize_cookies( $cookies ) { 458 $cookie_jar = new WpOrg\Requests\Cookie\Jar();458 $cookie_jar = new Requests_Cookie_Jar(); 459 459 460 460 foreach ( $cookies as $name => $value ) { … … 466 466 } 467 467 ); 468 $cookie_jar[ $value->name ] = new WpOrg\Requests\Cookie( $value->name, $value->value, $attributes, array( 'host-only' => $value->host_only ) );468 $cookie_jar[ $value->name ] = new Requests_Cookie( $value->name, $value->value, $attributes, array( 'host-only' => $value->host_only ) ); 469 469 } elseif ( is_scalar( $value ) ) { 470 $cookie_jar[ $name ] = new WpOrg\Requests\Cookie( $name, (string)$value );470 $cookie_jar[ $name ] = new Requests_Cookie( $name, $value ); 471 471 } 472 472 } … … 484 484 * @since 4.6.0 485 485 * 486 * @param string 487 * @param array 488 * @param string|array 489 * @param array 490 * @param WpOrg\Requests\Response $original Response object.486 * @param string $location URL to redirect to. 487 * @param array $headers Headers for the redirect. 488 * @param string|array $data Body to send with the request. 489 * @param array $options Redirect request options. 490 * @param Requests_Response $original Response object. 491 491 */ 492 492 public static function browser_redirect_compatibility( $location, $headers, $data, &$options, $original ) { 493 493 // Browser compatibility. 494 494 if ( 302 === $original->status_code ) { 495 $options['type'] = WpOrg\Requests\Requests::GET;495 $options['type'] = Requests::GET; 496 496 } 497 497 } … … 502 502 * @since 4.7.5 503 503 * 504 * @throws WpOrg\Requests\Exception On unsuccessful URL validation.504 * @throws Requests_Exception On unsuccessful URL validation. 505 505 * @param string $location URL to redirect to. 506 506 */ 507 507 public static function validate_redirects( $location ) { 508 508 if ( ! wp_http_validate_url( $location ) ) { 509 throw new WpOrg\Requests\Exception( __( 'A valid URL was not provided.' ), 'wp_http.redirect_failed_validation' );509 throw new Requests_Exception( __( 'A valid URL was not provided.' ), 'wp_http.redirect_failed_validation' ); 510 510 } 511 511 }
Note: See TracChangeset
for help on using the changeset viewer.