use PhpXmlRpc\Helper\Logger;
use PhpXmlRpc\Helper\XMLParser;
+
/**
* Used to represent a client of an XML-RPC server.
*/
* e.g. /xmlrpc/server.php
* e.g. http://phpxmlrpc.sourceforge.net/server.php
* e.g. https://james:bond@secret.service.com:443/xmlrpcserver?agent=007
+ * e.g. http2tls://fast-and-secure-services/endpoint
* @param string $server the server name / ip address
* @param integer $port the port the server is listening on, when omitted defaults to 80 or 443 depending on
* protocol used
* @param string $method the http protocol variant: defaults to 'http'; 'https', 'http11', 'http2' and 'http2tls' can
* be used if CURL is installed. The value set here can be overridden in any call to $this->send().
+ * Use 'http2' to make the lib attempt to use http/2 without tls and 'http2tls' for secure http/2
*/
public function __construct($path, $server = '', $port = '', $method = '')
{
* for $timeout seconds, the connection will be closed).
* @param string $method valid values are 'http', 'http11', 'https', 'http2' and 'http2tls'. If left unspecified,
* the http protocol chosen during creation of the object will be used.
+ * Use 'http2' to make the lib attempt to use http/2 without tls and 'http2tls' for secure http/2
*
* @return Response|Response[] Note that the client will always return a Response object, even if the call fails
* @todo allow throwing exceptions instead of returning responses in case of failed calls and/or Fault responses
}
}
- if (preg_match('/^HTTP\/[0-9](?:\.[0-9])? ([0-9]{3}) /', $data, $matches)) {
- $httpResponse['status_code'] = $matches[1];
+ if (preg_match('/^HTTP\/([0-9](?:\.[0-9])?) ([0-9]{3}) /', $data, $matches)) {
+ $httpResponse['protocol_version'] = $matches[1];
+ $httpResponse['status_code'] = $matches[2];
}
if ($httpResponse['status_code'] !== '200') {
if (is_array($r)) {
return $r;
}
+ $this->validateResponse($r);
if (is_array($errorCode)) {
$this->assertContains($r->faultCode(), $errorCode, 'Error ' . $r->faultCode() . ' connecting to server: ' . $r->faultString());
} else {
}
}
+ protected function validateResponse($r)
+ {
+ // to be implemented in subclasses
+ }
+
/**
* Adds (and replaces) query params to the url currently used by the client
* @param array $data
*/
class HTTPTest extends ServerTest
{
+ protected $expectHttp2 = false;
+
/**
* Returns all test methods from the base class, except the ones which failed already
*
{
$this->markTestSkipped('CURL missing: cannot test http/2');
return;
+ } else if (!defined('CURL_HTTP_VERSION_2'))
+ {
+ $this->markTestSkipped('CURL http/2 support missing: cannot test http/2');
+ return;
}
$this->method = 'http2'; // not an error the double assignment!
$this->client->method = 'http2';
//$this->client->keepalive = false; // q: is this a good idea?
+
+ $this->expectHttp2 = true;
$this->$method();
+ $this->expectHttp2 = false;
}
/**
{
$this->markTestSkipped('HTTPS SERVER definition missing: cannot test http/2 tls');
return;
+ } else if (!defined('CURL_HTTP_VERSION_2'))
+ {
+ $this->markTestSkipped('CURL http/2 support missing: cannot test http/2 tls');
+ return;
}
$this->client->server = $this->args['HTTPSSERVER'];
$this->client->setSSLVerifyHost($this->args['HTTPSVERIFYHOST']);
$this->client->setSSLVersion($this->args['SSLVERSION']);
+ $this->expectHttp2 = true;
$this->$method();
+ $this->expectHttp2 = false;
}
/**
$this->$method();
}
+
+ /**
+ * @param \PhpXmlRpc\Response $r
+ * @return void
+ */
+ protected function validateResponse($r)
+ {
+ /// @todo check $r->httpResponse()['protocol_version']
+ if ($this->expectHttp2) {
+
+ } else {
+
+ }
+ }
}
# HTTPSERVER
# TESTS_ROOT_DIR
-# Enable http2
-Protocols h2 h2c http/1.1
-
<VirtualHost *:80>
+ # Enable http2
+ Protocols h2c http/1.1
+
DocumentRoot ${TESTS_ROOT_DIR}
#ErrorLog "${TESTS_ROOT_DIR}/apache_error.log"
<VirtualHost _default_:443>
+ # Enable http2
+ Protocols h2 http/1.1
+
DocumentRoot ${TESTS_ROOT_DIR}
#ErrorLog "${TESTS_ROOT_DIR}/apache_error.log"