-XML-RPC for PHP version 4.2.3 - 2017/11/5
+XML-RPC for PHP version 4.3.0 - 2017/11/5
* fixed: compatibility with Basic/Digest/NTLM auth when using client in cURL mode (issue #55)
* improved: added unit tests for Basic and Digest http auth. Also improved unit tests for feature of the http protocol
+* new: allow to force usage of curl for http &.0 calls, as well as plain socket for https calls, via the method
+ `Client::setUseCurl()`
XML-RPC for PHP version 4.2.2 - 2017/10/15
*/
class Client
{
+ const USE_CURL_NEVER = 0;
+ const USE_CURL_ALWAYS = 1;
+ const USE_CURL_AUTO = 2;
+
/// @todo: do these need to be public?
public $method = 'http';
public $server;
public $cookies = array();
public $extracurlopts = array();
+ public $use_curl = self::USE_CURL_AUTO;
/**
* @var bool
*/
public $request_compression = '';
+
/**
* CURL handle: used for keep-alive connections (PHP 4.3.8 up, see:
* http://curl.haxx.se/docs/faq.html#7.3).
$this->accepted_charset_encodings = array('UTF-8', 'ISO-8859-1', 'US-ASCII');
// Add all charsets which mbstring can handle, but remove junk not found in IANA registry at
- // in http://www.iana.org/assignments/character-sets/character-sets.xhtml
+ // http://www.iana.org/assignments/character-sets/character-sets.xhtml
// NB: this is disabled to avoid making all the requests sent huge... mbstring supports more than 80 charsets!
/*if (function_exists('mb_list_encodings')) {
* This option can be very useful when debugging servers as it allows you to see exactly what the client sends and
* the server returns.
*
- * @param integer $in values 0, 1 and 2 are supported (2 = echo sent msg too, before received response)
+ * @param integer $level values 0, 1 and 2 are supported (2 = echo sent msg too, before received response)
*/
public function setDebug($level)
{
$this->extracurlopts = $options;
}
+ /**
+ * @param int $useCurlMode self::USE_CURL_ALWAYS, self::USE_CURL_AUTO or self::USE_CURL_NEVER
+ */
+ public function setUseCurl($useCurlMode)
+ {
+ $this->use_curl = $useCurlMode;
+ }
+
+
/**
* Set user-agent string that will be used by this client instance in http headers sent to the server.
*
$req->setDebug($this->debug);
/// @todo we could be smarter about this and force usage of curl in scenarios where it is both available and
- /// needed, such as digest or ntlm auth
- $useCurl = ($method == 'https' || $method == 'http11');
+ /// needed, such as digest or ntlm auth. Do not attempt to use it for https if not present
+ $useCurl = ($this->use_curl == self::USE_CURL_ALWAYS) || ($this->use_curl == self::USE_CURL_AUTO &&
+ ($method == 'https' || $method == 'http11'));
if ($useCurl) {
$r = $this->sendPayloadCURL(
public function getSingleHttpTestMethods()
{
$unsafeMethods = array(
- 'testHttps', 'testCatchExceptions', 'testUtf8Method', 'testServerComments',
+ 'testCatchExceptions', 'testUtf8Method', 'testServerComments',
'testExoticCharsetsRequests', 'testExoticCharsetsRequests2', 'testExoticCharsetsRequests3',
);
$this->$method();
}
+ /**
+ * @dataProvider getSingleHttpTestMethods
+ * @param string $method
+ */
+ public function testHttp10Curl($method)
+ {
+ if(!function_exists('curl_init'))
+ {
+ $this->markTestSkipped('CURL missing: cannot test http 1.1');
+ return;
+ }
+
+ $this->method = 'http10'; // not an error the double assignment!
+ $this->client->method = 'http10';
+ $this->client->keepalive = false;
+ $this->client->setUseCurl(\PhpXmlRpc\Client::USE_CURL_ALWAYS);
+
+ $this->$method();
+ }
+
/**
* @dataProvider getSingleHttpTestMethods
* @param string $method
$this->$method();
}
+ /**
+ * @dataProvider getSingleHttpTestMethods
+ * @param string $method
+ */
+ public function testHttpsSocket($method)
+ {
+ if ($this->args['HTTPSSERVER'] == '')
+ {
+ $this->markTestSkipped('HTTPS SERVER definition missing: cannot test https');
+ return;
+ }
+
+ $this->client->server = $this->args['HTTPSSERVER'];
+ $this->method = 'https';
+ $this->client->method = 'https';
+ $this->client->path = $this->args['HTTPSURI'];
+ $this->client->setSSLVerifyPeer(!$this->args['HTTPSIGNOREPEER']);
+ $this->client->setSSLVerifyHost($this->args['HTTPSVERIFYHOST']);
+ $this->client->setSSLVersion($this->args['SSLVERSION']);
+ $this->client->setUseCurl(\PhpXmlRpc\Client::USE_CURL_NEVER);
+
+ $this->$method();
+ }
+
/**
* @dataProvider getSingleHttpTestMethods
* @param string $method