Make WordPress Core


Ignore:
Timestamp:
12/06/2021 09:29:00 PM (2 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-http.php

    r52327 r52328  
    88 */
    99
    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' );
     10if ( ! 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' );
    1515}
    1616
     
    275275            $response = new WP_Error( 'http_request_failed', __( 'A valid URL was not provided.' ) );
    276276            /** 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 );
    278278            return $response;
    279279        }
     
    282282            $response = new WP_Error( 'http_request_not_executed', __( 'User has blocked requests through HTTP.' ) );
    283283            /** 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 );
    285285            return $response;
    286286        }
     
    299299                $response = new WP_Error( 'http_request_failed', __( 'Destination directory for file streaming does not exist or is not writable.' ) );
    300300                /** 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 );
    302302                return $response;
    303303            }
     
    347347        }
    348348
    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.
    350350        if ( ! empty( $parsed_args['cookies'] ) ) {
    351351            $options['cookies'] = WP_Http::normalize_cookies( $parsed_args['cookies'] );
     
    379379        $proxy = new WP_HTTP_Proxy();
    380380        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() );
    382382
    383383            if ( $proxy->use_authentication() ) {
     
    392392
    393393        try {
    394             $requests_response = WpOrg\Requests\Requests::request( $url, $headers, $data, $type, $options );
     394            $requests_response = Requests::request( $url, $headers, $data, $type, $options );
    395395
    396396            // Convert the response into an array.
     
    400400            // Add the original object to the array.
    401401            $response['http_response'] = $http_response;
    402         } catch ( WpOrg\Requests\Exception $e ) {
     402        } catch ( Requests_Exception $e ) {
    403403            $response = new WP_Error( 'http_request_failed', $e->getMessage() );
    404404        }
     
    417417         * @param string         $url         The request URL.
    418418         */
    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 );
    420420        if ( is_wp_error( $response ) ) {
    421421            return $response;
     
    453453     *
    454454     * @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.
    456456     */
    457457    public static function normalize_cookies( $cookies ) {
    458         $cookie_jar = new WpOrg\Requests\Cookie\Jar();
     458        $cookie_jar = new Requests_Cookie_Jar();
    459459
    460460        foreach ( $cookies as $name => $value ) {
     
    466466                    }
    467467                );
    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 ) );
    469469            } elseif ( is_scalar( $value ) ) {
    470                 $cookie_jar[ $name ] = new WpOrg\Requests\Cookie( $name, (string) $value );
     470                $cookie_jar[ $name ] = new Requests_Cookie( $name, $value );
    471471            }
    472472        }
     
    484484     * @since 4.6.0
    485485     *
    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 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.
    491491     */
    492492    public static function browser_redirect_compatibility( $location, $headers, $data, &$options, $original ) {
    493493        // Browser compatibility.
    494494        if ( 302 === $original->status_code ) {
    495             $options['type'] = WpOrg\Requests\Requests::GET;
     495            $options['type'] = Requests::GET;
    496496        }
    497497    }
     
    502502     * @since 4.7.5
    503503     *
    504      * @throws WpOrg\Requests\Exception On unsuccessful URL validation.
     504     * @throws Requests_Exception On unsuccessful URL validation.
    505505     * @param string $location URL to redirect to.
    506506     */
    507507    public static function validate_redirects( $location ) {
    508508        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' );
    510510        }
    511511    }
Note: See TracChangeset for help on using the changeset viewer.