#23520 [Asn]: PEAR Remote calls do not use Proxy Setting

From: Date: Fri, 11 Jul 2003 08:47:12 +0000
Subject: #23520 [Asn]: PEAR Remote calls do not use Proxy Setting
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-18167@lists.php.net to get a copy of this message
ID: 23520 Updated by: cox@php.net Reported By: aashley at optimiser dot com Status: Assigned Bug Type: PEAR related Operating System: Gentoo Linux (2.4.20) PHP Version: 4.3.2 Assigned To: cox New Comment: Hi, Please send the diff -u against the lastest CVS file (in the repository php-src/pear/PEAR/Remote.php) to me cox@idecnet.com, the patch posted here doesn't apply cleanly. Thanks, Tomas V.V.Cox Previous Comments: ------------------------------------------------------------------------ [2003-07-11 02:22:30] aashley at optimiser dot com hasnt been tested with authenticating proxies, but does work with non-authenticating squid we have running here. ------------------------------------------------------------------------ [2003-07-11 02:20:38] aashley at optimiser dot com --- Remote.orig.php 2003-07-11 15:01:28.000000000 +0800 +++ Remote.php 2003-07-11 15:13:07.000000000 +0800 @@ -204,8 +204,21 @@ return $this->raiseError("PEAR_Remote::call: no master_server configured"); } $server_port = 80; - $fp = @fsockopen($server_host, $server_port); - if (!$fp) { + $proxy_host = $proxy_port = $proxy_user = $proxy_pass = ''; + if ($proxy = parse_url($this->config->get('http_proxy'))) { + $proxy_host = @$proxy['host']; + $proxy_port = @$proxy['port']; + $proxy_user = @$proxy['user']; + $proxy_pass = @$proxy['pass']; + } + if ($proxy > '') { + $fp = @fsockopen($proxy_host, $proxy_port); + } else { + $fp = @fsockopen($server_host, $server_port); + } + if (!$fp && $proxy_host > '') { + return $this->raiseError("PEAR_Remote::call: fsockopen(`$proxy_host', $proxy_port) failed"); + } elseif (!$fp) { return $this->raiseError("PEAR_Remote::call: fsockopen(`$server_host', $server_port) failed"); } $len = strlen($request); @@ -225,14 +238,29 @@ $maxAge = ''; }; + if ($proxy_host > '' && $proxy_user > '') { + $req_headers .= 'Proxy-Authorization: Basic ' + .base64_encode($proxy_user.':'.$proxy_pass) + ."\r\n"; + } + if ($this->config->get('verbose') > 3) { print "XMLRPC REQUEST HEADERS:\n"; var_dump($req_headers); print "XMLRPC REQUEST BODY:\n"; var_dump($request); } + + if ($proxy_host > '') { + $post_string = "POST http://".$server_host; + if ($proxy_port > '') { + $post_string .= ':'.$server_port; + } + } else { + $post_string = "POST "; + } - fwrite($fp, ("POST /xmlrpc.php$maxAge HTTP/1.0\r\n$req_headers\r\n$request")); + fwrite($fp, ($post_string."/xmlrpc.php$maxAge HTTP/1.0\r\n$req_headers\r\n$request")); $response = ''; $line1 = fgets($fp, 2048); if (!preg_match('!^HTTP/[0-9\.]+ (\d+) (.*)!', $line1, $matches)) { ------------------------------------------------------------------------ [2003-07-11 02:16:39] arnaud@php.net Post the diff here ------------------------------------------------------------------------ [2003-07-11 02:13:18] aashley at optimiser dot com hrmm i really should learn when to call it quits and go home. anyway I have made a patch for PEAR/Remote.php based on the code in XML/RPC.php to fix this problem, where/how should I go about submitting it? ------------------------------------------------------------------------ [2003-07-11 02:12:46] arnaud@php.net can you have a look at it tomas ? ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/23520 -- Edit this bug report at http://bugs.php.net/?id=23520&edit=1

« previous php.pear.dev (#18167) next »