[wp-trac] [WordPress Trac] #37614: WP_PROXY_BYPASS_HOSTS has no effect inside curl transport, if http_proxy or https_proxy is set on the system

WordPress Trac noreply at wordpress.org
Wed Aug 10 13:05:44 UTC 2016


#37614: WP_PROXY_BYPASS_HOSTS has no effect inside curl transport, if http_proxy or
https_proxy is set on the system
--------------------------+------------------------------
 Reporter:  fliespl       |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  HTTP API      |     Version:
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by fliespl):

 I have just confirmed that it is valid in all version of wordpress up to
 trunk. Tested on Ubuntu 16.04 (doesn't happen on windows).

 Problem is because php curl will use system environment variable of
 http_proxy, https_proxy or other if set. That's why curl transport should
 set null to CURLOPT_PROXY.

 http_proxy & other might be set in: global server config, current profile
 config, php-fpm setup, apache setup.

 ---

 The easiest way to mimic http_proxy setting is to execute:

 `putenv('http_proxy=invalid.url:8888');` prior to executing
 `wp_remote_get`.

 It behaves as if it was set in server setup.


 I have created a sample pages to show the issue:
 Authorization: 37614 / 37614

 http://37614.wordpress.codeone.pl/ -> env variable is not set (works
 correctly)
 http://37614.wordpress.codeone.pl/?proxy=1 -> http_proxy env variable set
 to a proxy which is offline - causes proxy error even though

 And here's the sample code used (there's not definition of WP_PROXY
 anywhere in the code - yet it uses system settings):

 {{{
 <pre>
 <?php

 putenv('http_proxy=');

 if(isset($_GET['proxy']) && $_GET['proxy'] == '1') {
    putenv('http_proxy=offline.proxy.url:18888');
 }

 print 'ENV variable - http_proxy='.getenv('http_proxy')."\n";

 define('WP_PROXY_BYPASS_HOSTS', '*.wordpress.org, wordpress.org');

 $response = wp_remote_get('http://wordpress.org');
 if(is_wp_error($response)) {
     var_dump($response);
 } else {
     var_dump($response['headers']);
 }

 ?>
 </pre>
 <?php die; ?>
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/37614#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list