THRIFT-99. php: Add scheme (http[s], etc.) support to THttpClient
authorDavid Reiss <dreiss@apache.org>
Sun, 27 Jul 2008 23:41:13 +0000 (23:41 +0000)
committerDavid Reiss <dreiss@apache.org>
Sun, 27 Jul 2008 23:41:13 +0000 (23:41 +0000)
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@680211 13f79535-47bb-0310-9956-ffa450edef68

lib/php/src/transport/THttpClient.php

index d5d03c4..9ac1370 100644 (file)
@@ -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) {