2013-03-11 Kikuchi Koichiro <koichiro@rworks.jp>
* extensions/update_manager/lib/libupdate_manager_client.php, extensions/update_manager/lib/xmlrpc/xmlrpc.inc: Added HTTP redirect support. It fixes an issue that update manager behind http proxy failed to communicate with update server due to the server's "301 Moved Permanently" HTTP response. Merged from: branch_4.0 > Description of fields to fill in above: 76 columns --| > PR: If a GNATS PR is affected by the change. > Submitted by: If someone else sent in the change. > Reviewed by: If someone else reviewed your modification. > Approved by: If you needed approval for this commit. > Obtained from: If the change is from a third party. > MFC after: N [day[s]|week[s]|month[s]]. Request a reminder email. > Security: Vulnerability reference (one per line) or description. > Empty fields above will be automatically removed. _M pandora_console M pandora_console/ChangeLog M pandora_console/extensions/update_manager/lib/xmlrpc/xmlrpc.inc M pandora_console/extensions/update_manager/lib/libupdate_manager_client.php git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7822 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
9fdd4e5262
commit
514a5546be
|
@ -1,3 +1,13 @@
|
|||
2013-03-11 Kikuchi Koichiro <koichiro@rworks.jp>
|
||||
|
||||
* extensions/update_manager/lib/libupdate_manager_client.php,
|
||||
extensions/update_manager/lib/xmlrpc/xmlrpc.inc: Added HTTP redirect
|
||||
support. It fixes an issue that update manager behind http proxy
|
||||
failed to communicate with update server due to the server's
|
||||
"301 Moved Permanently" HTTP response.
|
||||
|
||||
Merged from: branch_4.0
|
||||
|
||||
2013-03-08 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* godmode/agentes/planned_downtime.list.php: added event when some
|
||||
|
|
|
@ -32,6 +32,7 @@ function um_xml_rpc_client_call ($server_host, $server_path, $server_port, $prox
|
|||
$client = new xmlrpc_client($server_path, $server_host, $server_port);
|
||||
|
||||
$client->setProxy($proxy, $proxy_port, $proxy_user, $proxy_pass);
|
||||
$client->setFollowLocation(true);
|
||||
|
||||
if (defined ('XMLRPC_DEBUG'))
|
||||
$client->setDebug (XMLRPC_DEBUG);
|
||||
|
|
|
@ -829,6 +829,9 @@
|
|||
var $proxy_authtype=1;
|
||||
var $cookies=array();
|
||||
var $extracurlopts=array();
|
||||
var $followlocation=false;
|
||||
var $maxredirs=50;
|
||||
var $redirs=0;
|
||||
|
||||
/**
|
||||
* List of http compression methods accepted by the client for responses.
|
||||
|
@ -877,50 +880,27 @@
|
|||
// allow user to specify all params in $path
|
||||
if($server == '' and $port == '' and $method == '')
|
||||
{
|
||||
$parts = parse_url($path);
|
||||
$server = $parts['host'];
|
||||
$path = isset($parts['path']) ? $parts['path'] : '';
|
||||
if(isset($parts['query']))
|
||||
{
|
||||
$path .= '?'.$parts['query'];
|
||||
}
|
||||
if(isset($parts['fragment']))
|
||||
{
|
||||
$path .= '#'.$parts['fragment'];
|
||||
}
|
||||
if(isset($parts['port']))
|
||||
{
|
||||
$port = $parts['port'];
|
||||
}
|
||||
if(isset($parts['scheme']))
|
||||
{
|
||||
$method = $parts['scheme'];
|
||||
}
|
||||
if(isset($parts['user']))
|
||||
{
|
||||
$this->username = $parts['user'];
|
||||
}
|
||||
if(isset($parts['pass']))
|
||||
{
|
||||
$this->password = $parts['pass'];
|
||||
}
|
||||
}
|
||||
if($path == '' || $path[0] != '/')
|
||||
{
|
||||
$this->path='/'.$path;
|
||||
setup_by_path($path);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->path=$path;
|
||||
}
|
||||
$this->server=$server;
|
||||
if($port != '')
|
||||
{
|
||||
$this->port=$port;
|
||||
}
|
||||
if($method != '')
|
||||
{
|
||||
$this->method=$method;
|
||||
if($path == '' || $path[0] != '/')
|
||||
{
|
||||
$this->path='/'.$path;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->path=$path;
|
||||
}
|
||||
$this->server=$server;
|
||||
if($port != '')
|
||||
{
|
||||
$this->port=$port;
|
||||
}
|
||||
if($method != '')
|
||||
{
|
||||
$this->method=$method;
|
||||
}
|
||||
}
|
||||
|
||||
// if ZLIB is enabled, let the client by default accept compressed responses
|
||||
|
@ -942,6 +922,46 @@
|
|||
$this->user_agent = $GLOBALS['xmlrpcName'] . ' ' . $GLOBALS['xmlrpcVersion'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup parameters by $path
|
||||
* @access private
|
||||
*/
|
||||
function setup_by_path($path)
|
||||
{
|
||||
$parts = parse_url($path);
|
||||
$this->server = $parts['host'];
|
||||
$path = isset($parts['path']) ? $parts['path'] : '';
|
||||
if(isset($parts['query']))
|
||||
{
|
||||
$path .= '?'.$parts['query'];
|
||||
}
|
||||
if(isset($parts['fragment']))
|
||||
{
|
||||
$path .= '#'.$parts['fragment'];
|
||||
}
|
||||
if(isset($parts['user']))
|
||||
{
|
||||
$this->username = $parts['user'];
|
||||
}
|
||||
if(isset($parts['pass']))
|
||||
{
|
||||
$this->password = $parts['pass'];
|
||||
}
|
||||
if($path == '' || $path[0] != '/')
|
||||
{
|
||||
$path = '/' . $path;
|
||||
}
|
||||
$this->path=$path;
|
||||
if(isset($parts['port']))
|
||||
{
|
||||
$this->port = $parts['port'];
|
||||
}
|
||||
if(isset($parts['scheme']))
|
||||
{
|
||||
$this->method = $parts['scheme'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables/disables the echoing to screen of the xmlrpc responses received
|
||||
* @param integer $debug values 0, 1 and 2 are supported (2 = echo sent msg too, before received response)
|
||||
|
@ -1106,6 +1126,25 @@
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set follow Location: header or not when server response is 301, 302 or 303.
|
||||
* @param bool $follow
|
||||
*/
|
||||
function setFollowLocation( $follow )
|
||||
{
|
||||
$this->followlocation = $follow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set maximum number of redirection-followings allowed. By default, the limit
|
||||
* is set to 50 redirections. Set this option to -1 to make it limitless.
|
||||
* @param int $num
|
||||
*/
|
||||
function setMaxRedirs( $num )
|
||||
{
|
||||
$this->maxredirs = $num;
|
||||
}
|
||||
|
||||
/**
|
||||
* Directly set cURL options, for extra flexibility
|
||||
* It allows eg. to bind client to a specific IP interface / address
|
||||
|
@ -1407,8 +1446,23 @@
|
|||
$ipd.=fread($fp, 32768);
|
||||
} while(!feof($fp));
|
||||
fclose($fp);
|
||||
|
||||
$r =& $msg->parseResponse($ipd, false, $this->return_type);
|
||||
|
||||
// Handle Redirect
|
||||
if ($this->followlocation
|
||||
&& preg_match('/^HTTP\/[0-9.]+ 30[123] /', $ipd)
|
||||
&& $this->redirs < $this->maxredirs
|
||||
&& preg_match('/\r\nLocation:\s*([^\r\n]+)/', $ipd, $m)) {
|
||||
|
||||
if ($this->maxredirs != -1)
|
||||
{
|
||||
$this->redirs++;
|
||||
}
|
||||
$this->setup_by_path($m[1]);
|
||||
$r =& $this->send($msg, $timeout);
|
||||
} else {
|
||||
$r =& $msg->parseResponse($ipd, false, $this->return_type);
|
||||
$this->redirs = 0;
|
||||
}
|
||||
return $r;
|
||||
|
||||
}
|
||||
|
@ -1537,6 +1591,10 @@
|
|||
// return the header too
|
||||
curl_setopt($curl, CURLOPT_HEADER, 1);
|
||||
|
||||
// redirect
|
||||
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, $this->followlocation);
|
||||
curl_setopt($curl, CURLOPT_MAXREDIRS, $this->maxredirs);
|
||||
|
||||
// will only work with PHP >= 5.0
|
||||
// NB: if we set an empty string, CURL will add http header indicating
|
||||
// ALL methods it is supporting. This is possibly a better option than
|
||||
|
@ -3775,4 +3833,4 @@ xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $cha
|
|||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue