当前位置: 首页>>代码示例>>PHP>>正文


PHP JUri::isSsl方法代码示例

本文整理汇总了PHP中JUri::isSsl方法的典型用法代码示例。如果您正苦于以下问题:PHP JUri::isSsl方法的具体用法?PHP JUri::isSsl怎么用?PHP JUri::isSsl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JUri的用法示例。


在下文中一共展示了JUri::isSsl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testIsSsl

 /**
  * Test the isSSL method.
  *
  * @return  void
  *
  * @since   11.1
  * @covers  JUri::isSsl
  */
 public function testIsSsl()
 {
     $this->object->parse('https://someuser:somepass@www.example.com:80/path/file.html?var=value#fragment');
     $this->assertThat($this->object->isSsl(), $this->equalTo(true));
     $this->object->parse('http://someuser:somepass@www.example.com:80/path/file.html?var=value#fragment');
     $this->assertThat($this->object->isSsl(), $this->equalTo(false));
 }
开发者ID:deenison,项目名称:joomla-cms,代码行数:15,代码来源:JURITest.php

示例2: connect

 /**
  * Method to connect to a server and get the resource.
  *
  * @param   JUri     $uri      The URI to connect with.
  * @param   integer  $timeout  Read timeout in seconds.
  *
  * @return  resource  Socket connection resource.
  *
  * @since   11.3
  * @throws  RuntimeException
  */
 protected function connect(JUri $uri, $timeout = null)
 {
     $errno = null;
     $err = null;
     // Get the host from the uri.
     $host = $uri->isSsl() ? 'ssl://' . $uri->getHost() : $uri->getHost();
     // If the port is not explicitly set in the URI detect it.
     if (!$uri->getPort()) {
         $port = $uri->getScheme() == 'https' ? 443 : 80;
     } else {
         $port = $uri->getPort();
     }
     // Build the connection key for resource memory caching.
     $key = md5($host . $port);
     // If the connection already exists, use it.
     if (!empty($this->connections[$key]) && is_resource($this->connections[$key])) {
         // Connection reached EOF, cannot be used anymore
         $meta = stream_get_meta_data($this->connections[$key]);
         if ($meta['eof']) {
             if (!fclose($this->connections[$key])) {
                 throw new RuntimeException('Cannot close connection');
             }
         } elseif (!$meta['timed_out']) {
             return $this->connections[$key];
         }
     }
     if (!is_numeric($timeout)) {
         $timeout = ini_get('default_socket_timeout');
     }
     // Capture PHP errors
     $php_errormsg = '';
     $track_errors = ini_get('track_errors');
     ini_set('track_errors', true);
     // PHP sends a warning if the uri does not exists; we silence it and throw an exception instead.
     // Attempt to connect to the server
     $connection = @fsockopen($host, $port, $errno, $err, $timeout);
     if (!$connection) {
         if (!$php_errormsg) {
             // Error but nothing from php? Create our own
             $php_errormsg = sprintf('Could not connect to resource: %s', $uri, $err, $errno);
         }
         // Restore error tracking to give control to the exception handler
         ini_set('track_errors', $track_errors);
         throw new RuntimeException($php_errormsg);
     }
     // Restore error tracking to what it was before.
     ini_set('track_errors', $track_errors);
     // Since the connection was successful let's store it in case we need to use it later.
     $this->connections[$key] = $connection;
     // If an explicit timeout is set, set it.
     if (isset($timeout)) {
         stream_set_timeout($this->connections[$key], (int) $timeout);
     }
     return $this->connections[$key];
 }
开发者ID:grlf,项目名称:eyedock,代码行数:66,代码来源:socket.php


注:本文中的JUri::isSsl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。