THRIFT-99. php: Add scheme (http[s], etc.) support to THttpClient
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@680211 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/php/src/transport/THttpClient.php b/lib/php/src/transport/THttpClient.php
index d5d03c4..9ac1370 100644
--- a/lib/php/src/transport/THttpClient.php
+++ b/lib/php/src/transport/THttpClient.php
@@ -41,6 +41,13 @@
protected $uri_;
/**
+ * The scheme to use for the request, i.e. http, https
+ *
+ * @var string
+ */
+ protected $scheme_;
+
+ /**
* Buffer for the HTTP request data
*
* @var string
@@ -68,10 +75,11 @@
* @param int $port
* @param string $uri
*/
- public function __construct($host, $port=80, $uri='') {
+ public function __construct($host, $port=80, $uri='', $scheme = 'http') {
if ((strlen($uri) > 0) && ($uri{0} != '/')) {
$uri = '/'.$uri;
}
+ $this->scheme_ = $scheme;
$this->host_ = $host;
$this->port_ = $port;
$this->uri_ = $uri;
@@ -170,7 +178,7 @@
$this->buf_ = '';
$contextid = stream_context_create(array('http' => $options));
- $this->handle_ = @fopen('http://'.$host.$this->uri_, 'r', false, $contextid);
+ $this->handle_ = @fopen($this->scheme_.'://'.$host.$this->uri_, 'r', false, $contextid);
// Connect failed?
if ($this->handle_ === FALSE) {