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