#23520 [Asn]: PEAR Remote calls do not use Proxy Setting
| From: | aashley at optimiser dot com | Date: | Fri, 11 Jul 2003 07:20:39 +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-18162@lists.php.net to get a copy of this message | ||
ID: 23520
User updated by: aashley at optimiser dot com
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:
--- 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)) {
Previous Comments:
------------------------------------------------------------------------
[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 ?
------------------------------------------------------------------------
[2003-07-11 01:52:14] aashley at optimiser dot com
okay i found where the problem in the code is. In PEAR_Remote when
doing an XMLRPC call if the xmlrpc extension is available then it is
used directly without using the XML_RPC object.
the problem is in that PEAR_Remote::call_epi() does not make use of the
proxy settings at all, while PEAR_Remote::call() if making use of the
XML_RPC object does.
------------------------------------------------------------------------
[2003-07-11 01:33:52] aashley at optimiser dot com
yeah I'll have a go at it prob monday morning, its almost knock off
time on friday here at the moment :)
------------------------------------------------------------------------
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