#23520 [Asn->Csd]: PEAR Remote calls do not use Proxy Setting
| From: | cox@php.net | Date: | Sat, 12 Jul 2003 14:31:11 +0000 |
| Subject: | #23520 [Asn->Csd]: PEAR Remote calls do not use Proxy Setting | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-18194@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
+Status: Closed
Bug Type: PEAR related
Operating System: Gentoo Linux (2.4.20)
PHP Version: 4.3.2
Assigned To: cox
New Comment:
I've commited your patch, will be included in the next PEAR package
release.
Thanks!
Previous Comments:
------------------------------------------------------------------------
[2003-07-11 03:47:10] cox@php.net
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
------------------------------------------------------------------------
[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?
------------------------------------------------------------------------
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