From 7fccd0ba4fc248478f485ddd4683d6f6608afa4b Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Wed, 13 Jul 2016 15:50:58 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@38054 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-http.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/wp-includes/class-http.php b/src/wp-includes/class-http.php index 692b499778..8360abcb03 100644 --- a/src/wp-includes/class-http.php +++ b/src/wp-includes/class-http.php @@ -347,6 +347,17 @@ class WP_Http { */ $options['verify'] = apply_filters( 'https_ssl_verify', $options['verify'] ); + // Check for proxies. + $proxy = new WP_HTTP_Proxy(); + if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) { + $options['proxy'] = new Requests_Proxy_HTTP( $proxy->host() . ':' . $proxy->port() ); + + if ( $proxy->use_authentication() ) { + $options['proxy']->user = $proxy->username(); + $options['proxy']->pass = $proxy->password(); + } + } + try { $requests_response = Requests::request( $url, $headers, $data, $type, $options );