svn: /pear/packages/XML_RPC2/trunk/XML/RPC2/ Backend/Php/Client.php Backend/Xmlrpcext/Client.php Client.php Util/HTTPRequest.php

From: Date: Sat, 26 Feb 2011 17:02:48 +0000
Subject: svn: /pear/packages/XML_RPC2/trunk/XML/RPC2/ Backend/Php/Client.php Backend/Xmlrpcext/Client.php Client.php Util/HTTPRequest.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-61284@lists.php.net to get a copy of this message
sergiosgc Sat, 26 Feb 2011 17:02:48 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=308706 Log: Fix Request #15068 Use HTTP_Request2 rather than cURL Bug: http://pear.php.net/bugs/15068 (unknown) Changed paths: U pear/packages/XML_RPC2/trunk/XML/RPC2/Backend/Php/Client.php U pear/packages/XML_RPC2/trunk/XML/RPC2/Backend/Xmlrpcext/Client.php U pear/packages/XML_RPC2/trunk/XML/RPC2/Client.php U pear/packages/XML_RPC2/trunk/XML/RPC2/Util/HTTPRequest.php Modified: pear/packages/XML_RPC2/trunk/XML/RPC2/Backend/Php/Client.php =================================================================== --- pear/packages/XML_RPC2/trunk/XML/RPC2/Backend/Php/Client.php 2011-02-26 17:02:23 UTC (rev 308705) +++ pear/packages/XML_RPC2/trunk/XML/RPC2/Backend/Php/Client.php 2011-02-26 17:02:48 UTC (rev 308706) @@ -109,6 +109,7 @@ 'sslverify' => $this->sslverify, 'connectionTimeout' => $this->connectionTimeout ); + if (isset($this->httpRequest)) $options['httpRequest'] = $this->httpRequest; $httpRequest = new XML_RPC2_Util_HTTPRequest($uri, $options); $httpRequest->setPostData($request); $httpRequest->sendRequest(); Modified: pear/packages/XML_RPC2/trunk/XML/RPC2/Backend/Xmlrpcext/Client.php =================================================================== --- pear/packages/XML_RPC2/trunk/XML/RPC2/Backend/Xmlrpcext/Client.php 2011-02-26 17:02:23 UTC (rev 308705) +++ pear/packages/XML_RPC2/trunk/XML/RPC2/Backend/Xmlrpcext/Client.php 2011-02-26 17:02:48 UTC (rev 308706) @@ -107,6 +107,7 @@ 'sslverify' => $this->sslverify, 'connectionTimeout' => $this->connectionTimeout ); + if (isset($this->httpRequest)) $options['httpRequest'] = $this->httpRequest; $httpRequest = new XML_RPC2_Util_HTTPRequest($uri, $options); $httpRequest->setPostData($request); $httpRequest->sendRequest(); Modified: pear/packages/XML_RPC2/trunk/XML/RPC2/Client.php =================================================================== --- pear/packages/XML_RPC2/trunk/XML/RPC2/Client.php 2011-02-26 17:02:23 UTC (rev 308705) +++ pear/packages/XML_RPC2/trunk/XML/RPC2/Client.php 2011-02-26 17:02:48 UTC (rev 308706) @@ -136,6 +136,13 @@ * see XML_RPC2_Backend_Xmlrpcext_Value::createFromNative() from more infos */ protected $uglyStructHack = true; + + /** + * Preconfigured HTTP_Request2 provided by the user + * + * @var HTTP_Request2 + */ + protected $httpRequest = null; // }}} // {{{ constructor @@ -146,6 +153,10 @@ * To create a new XML_RPC2_Client, a URI must be provided (e.g. http://xmlrpc.example.com/1.0/). * Optionally, some options may be set as an associative array. Accepted keys are : * 'prefix', 'proxy', 'debug' => see correspondant property to get more informations + * 'encoding' => The XML encoding for the requests (optional, defaults to utf-8) + * 'sslverify' => boolean, true iff SSL certificates are to be verified against local cert database (optional, default false) + * 'connectionTimeout' => Timeout, in seconds, for the XML-RPC HTTP request (optional, default is no timeout) + * 'httpRequest' => Preconfigured HTTP_Request2 instance to be used in executing the XML-RPC calls (optional) * * @param string URI for the XML-RPC server * @param array (optional) Associative array of options @@ -197,6 +208,9 @@ } $this->connectionTimeout = $options['connectionTimeout']; } + if (isset($options['httpRequest'])) { + $this->httpRequest = $options['httpRequest']; + } } // }}} Modified: pear/packages/XML_RPC2/trunk/XML/RPC2/Util/HTTPRequest.php =================================================================== --- pear/packages/XML_RPC2/trunk/XML/RPC2/Util/HTTPRequest.php 2011-02-26 17:02:23 UTC (rev 308705) +++ pear/packages/XML_RPC2/trunk/XML/RPC2/Util/HTTPRequest.php 2011-02-26 17:02:48 UTC (rev 308706) @@ -110,6 +110,13 @@ */ private $_connectionTimeout = null; + /** + * HTTP_Request2 backend + * + * @var integer + */ + private $_httpRequest = null; + // }}} // {{{ getBody() @@ -150,6 +157,7 @@ * <li>encoding - The request encoding (string)</li> * <li>sslverify</li> - The SSL verify flag (boolean)</li> * <li>connectionTimeout</li> - The connection timeout in milliseconds (integer)</li> + * <li>httpRequest</li> - Preconfigured instance of HTTP_Request2 (optional) * </ul> * @access public */ @@ -181,6 +189,9 @@ if (isset($params['connectionTimeout'])) { $this->_connectionTimeout = $params['connectionTimeout']; } + if (isset($params['httpRequest'])) { + $this->_httpRequest = $params['httpRequest']; + } } // }}} @@ -194,7 +205,10 @@ */ public function sendRequest() { - $request = new HTTP_Request2($this->_uri, HTTP_Request2::METHOD_POST); + if (is_null($this->_httpRequest)) $this->_httpRequest = new HTTP_Request2($this->_uri, HTTP_Request2::METHOD_POST); + $request = $this->_httpRequest; + $request->setUrl($this->_uri); + $request->setMethod(HTTP_Request2::METHOD_POST); if (isset($params['proxy'])) { $elements = parse_url($params['proxy']); if (is_array($elements)) { @@ -225,45 +239,6 @@ } $this->_body = $result->getBody(); return $result->getBody(); - - - - -/* - if (!function_exists('curl_init') && - !( PEAR::loadExtension('php_curl') )) { - throw new XML_RPC2_CurlException('cURI extension is not present and load failed'); - } - if ($ch = curl_init()) { - if ( -// (is_null($this->_proxy) || curl_setopt($ch, CURLOPT_PROXY, $this->_proxy)) && -// (is_null($this->_proxyAuth) || curl_setopt($ch, CURLOPT_PROXYUSERPWD, $this->_proxyAuth)) && -// curl_setopt($ch, CURLOPT_URL, $this->_uri) && -//? curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE) && -// curl_setopt($ch, CURLOPT_POST, 1) && -// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->_sslverify) && -// curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $this->_sslverify) && -// curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: text/xml; charset='.$this->_encoding, 'User-Agent: PEAR::XML_RPC2/@package_version@')) && -// curl_setopt($ch, CURLOPT_POSTFIELDS, $this->_postData) && -// (!isset($this->_connectionTimeout) || curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, $this->_connectionTimeout)) - ) { - $result = curl_exec($ch); -// if (($errno = curl_errno($ch)) != 0) { -// throw new XML_RPC2_CurlException("Curl returned non-null errno $errno:" . curl_error($ch), $errno); -// } -// $info = curl_getinfo($ch); -// if ($info['http_code'] != 200) { -// throw new XML_RPC2_ReceivedInvalidStatusCodeException('Curl returned non 200 HTTP code: ' . $info['http_code'] . '. Response body:' . $result, $info['http_code']); - } - } else { - throw new XML_RPC2_CurlException('Unable to setup curl'); - } - } else { - throw new XML_RPC2_CurlException('Unable to init curl'); - } - $this->_body = $result; - return true; - */ } // }}}

« previous php.pear.cvs (#61284) next »