From 1f5ce50186de5dcd753b68d8a80428dd4913ba75 Mon Sep 17 00:00:00 2001 From: David Reiss Date: Sun, 27 Jul 2008 23:41:13 +0000 Subject: [PATCH] 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 --- lib/php/src/transport/THttpClient.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/php/src/transport/THttpClient.php b/lib/php/src/transport/THttpClient.php index d5d03c41..9ac13704 100644 --- a/lib/php/src/transport/THttpClient.php +++ b/lib/php/src/transport/THttpClient.php @@ -40,6 +40,13 @@ class THttpClient extends TTransport { */ protected $uri_; + /** + * The scheme to use for the request, i.e. http, https + * + * @var string + */ + protected $scheme_; + /** * Buffer for the HTTP request data * @@ -68,10 +75,11 @@ class THttpClient extends TTransport { * @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 @@ class THttpClient extends TTransport { $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) { -- 2.17.1