예제 #1
0
 /**
  *
  * @return SimpleHttpHandler|HttpTunnelHandler
  */
 public function createHttpHandler()
 {
     $overrideHosts = $this->getOverrideHosts();
     $ssl = "";
     if ($overrideHosts) {
         $s = $overrideHosts;
         if (strlen($s) > 2 && $s[1] == ':') {
             if ($s[0] == 's') {
                 $ssl = "ssl://";
             }
             $s = substr($s, 2);
         }
         $webCtx = strpos($s, "//");
         if ($webCtx) {
             $host = substr($s, 0, $webCtx);
         } else {
             $host = $s;
         }
         $idx = strpos($host, ':');
         if ($idx) {
             if ($webCtx) {
                 $port = substr($host, $idx + 1, $webCtx);
             } else {
                 $port = substr($host, $idx + 1);
             }
             $host = substr($host, 0, $idx);
         } else {
             $port = "8080";
         }
         if ($webCtx) {
             $webCtx = substr($s, $webCtx + 1);
         }
         $this->webContext = $webCtx;
     } else {
         $hostVec = Protocol::getHost();
         if ($ssl = $hostVec[0]) {
             $ssl .= "://";
         }
         $host = $hostVec[1];
         $port = $hostVec[2];
     }
     $this->serverName = "{$ssl}{$host}:{$port}";
     if (array_key_exists("X_JAVABRIDGE_REDIRECT", $_SERVER) || array_key_exists("HTTP_X_JAVABRIDGE_REDIRECT", $_SERVER)) {
         return new SimpleHttpHandler($this, $ssl, $host, $port);
     }
     return new HttpTunnelHandler($this, $ssl, $host, $port);
 }