Make WordPress Core

Changeset 38054


Ignore:
Timestamp:
07/13/2016 03:50:58 PM (8 years ago)
Author:
ocean90
Message:

HTTP API: Pass proxy settings to Requests.

WP_HTTP_Proxy() is used directly in WP_Http_Curl() and WP_Http_Streams(). Since WP_Http::request() doesn't use them anymore we have to move the proxy handling into WP_Http::request() so the proxy data can be passed to Requests::request().

Props rmccue.
See #33055.
Fixes #37107.

File:
1 edited

Legend:

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

    r38043 r38054  
    348348        $options['verify'] = apply_filters( 'https_ssl_verify', $options['verify'] );
    349349
     350        // Check for proxies.
     351        $proxy = new WP_HTTP_Proxy();
     352        if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) {
     353            $options['proxy'] = new Requests_Proxy_HTTP( $proxy->host() . ':' . $proxy->port() );
     354
     355            if ( $proxy->use_authentication() ) {
     356                $options['proxy']->user = $proxy->username();
     357                $options['proxy']->pass = $proxy->password();
     358            }
     359        }
     360
    350361        try {
    351362            $requests_response = Requests::request( $url, $headers, $data, $type, $options );
Note: See TracChangeset for help on using the changeset viewer.