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


PHP Net_URL2::getPort方法代码示例

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


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

示例1: parse

 /**
  * Parses the config and splits up the port + url
  * @return array
  */
 public function parse()
 {
     $proxy = $this->config->getSystemValue('proxy');
     $userpasswd = $this->config->getSystemValue('proxyuserpwd');
     $result = ['host' => null, 'port' => null, 'user' => null, 'password' => null];
     // we need to filter out the port -.-
     $url = new \Net_URL2($proxy);
     $port = $url->getPort();
     $url->setPort(false);
     $host = $url->getUrl();
     $result['host'] = $host;
     $result['port'] = $port;
     if ($userpasswd) {
         $auth = explode(':', $userpasswd, 2);
         $result['user'] = $auth[0];
         $result['password'] = $auth[1];
     }
     return $result;
 }
开发者ID:cs-team,项目名称:news,代码行数:23,代码来源:proxyconfigparser.php

示例2: setConfig

 /**
  * Sets the configuration parameter(s)
  *
  * The following parameters are available:
  * <ul>
  *   <li> 'adapter'           - adapter to use (string)</li>
  *   <li> 'connect_timeout'   - Connection timeout in seconds (integer)</li>
  *   <li> 'timeout'           - Total number of seconds a request can take.
  *                              Use 0 for no limit, should be greater than
  *                              'connect_timeout' if set (integer)</li>
  *   <li> 'use_brackets'      - Whether to append [] to array variable names (bool)</li>
  *   <li> 'protocol_version'  - HTTP Version to use, '1.0' or '1.1' (string)</li>
  *   <li> 'buffer_size'       - Buffer size to use for reading and writing (int)</li>
  *   <li> 'store_body'        - Whether to store response body in response object.
  *                              Set to false if receiving a huge response and
  *                              using an Observer to save it (boolean)</li>
  *   <li> 'local_ip'          - Specifies the IP address that will be used for accessing
  *                              the network (string)</li>
  *   <li> 'proxy_type'        - Proxy type, 'http' or 'socks5' (string)</li>
  *   <li> 'proxy_host'        - Proxy server host (string)</li>
  *   <li> 'proxy_port'        - Proxy server port (integer)</li>
  *   <li> 'proxy_user'        - Proxy auth username (string)</li>
  *   <li> 'proxy_password'    - Proxy auth password (string)</li>
  *   <li> 'proxy_auth_scheme' - Proxy auth scheme, one of HTTP_Request2::AUTH_* constants (string)</li>
  *   <li> 'proxy'             - Shorthand for proxy_* parameters, proxy given as URL,
  *                              e.g. 'socks5://localhost:1080/' (string)</li>
  *   <li> 'ssl_verify_peer'   - Whether to verify peer's SSL certificate (bool)</li>
  *   <li> 'ssl_verify_host'   - Whether to check that Common Name in SSL
  *                              certificate matches host name (bool)</li>
  *   <li> 'ssl_cafile'        - Cerificate Authority file to verify the peer
  *                              with (use with 'ssl_verify_peer') (string)</li>
  *   <li> 'ssl_capath'        - Directory holding multiple Certificate
  *                              Authority files (string)</li>
  *   <li> 'ssl_local_cert'    - Name of a file containing local cerificate (string)</li>
  *   <li> 'ssl_passphrase'    - Passphrase with which local certificate
  *                              was encoded (string)</li>
  *   <li> 'digest_compat_ie'  - Whether to imitate behaviour of MSIE 5 and 6
  *                              in using URL without query string in digest
  *                              authentication (boolean)</li>
  *   <li> 'follow_redirects'  - Whether to automatically follow HTTP Redirects (boolean)</li>
  *   <li> 'max_redirects'     - Maximum number of redirects to follow (integer)</li>
  *   <li> 'strict_redirects'  - Whether to keep request method on redirects via status 301 and
  *                              302 (true, needed for compatibility with RFC 2616)
  *                              or switch to GET (false, needed for compatibility with most
  *                              browsers) (boolean)</li>
  * </ul>
  *
  * @param string|array $nameOrConfig configuration parameter name or array
  *                                   ('parameter name' => 'parameter value')
  * @param mixed        $value        parameter value if $nameOrConfig is not an array
  *
  * @return   HTTP_Request2
  * @throws   HTTP_Request2_LogicException If the parameter is unknown
  */
 public function setConfig($nameOrConfig, $value = null)
 {
     if (is_array($nameOrConfig)) {
         foreach ($nameOrConfig as $name => $value) {
             $this->setConfig($name, $value);
         }
     } elseif ('proxy' == $nameOrConfig) {
         $url = new Net_URL2($value);
         $this->setConfig(array('proxy_type' => $url->getScheme(), 'proxy_host' => $url->getHost(), 'proxy_port' => $url->getPort(), 'proxy_user' => rawurldecode($url->getUser()), 'proxy_password' => rawurldecode($url->getPassword())));
     } else {
         if (!array_key_exists($nameOrConfig, $this->config)) {
             throw new HTTP_Request2_LogicException("Unknown configuration parameter '{$nameOrConfig}'", HTTP_Request2_Exception::INVALID_ARGUMENT);
         }
         $this->config[$nameOrConfig] = $value;
     }
     return $this;
 }
开发者ID:OPIN-CA,项目名称:w3c_validator,代码行数:71,代码来源:Request2.php

示例3: __get

 /**
  * Property getter interceptor to handle "uri" and "host" special cases.
  *
  * @param string $property The property to retrieve
  * 
  * @return mixed
  */
 public function __get($property)
 {
     switch ($property) {
         case 'uri':
             if ($this->_uri !== null) {
                 return $this->_uri->getURL();
             }
             return null;
         case 'proxy':
             return $this->_proxy;
         case 'path':
             if ($this->_uri === null) {
                 return null;
             }
             if ($this->httpVersion == self::HTTP_VERSION_1_0 || $this->proxy) {
                 // if http 1.0 or proxy given, the request uri must be absolute
                 return $this->_uri->getURL();
             }
             if (($path = $this->_uri->getPath()) === false) {
                 $path = '/';
             }
             if (($query = $this->_uri->getQuery()) !== false) {
                 $path .= '?' . $query;
             }
             if (($fragment = $this->_uri->getFragment()) !== false) {
                 $path .= '#' . $fragment;
             }
             return $path;
         case 'host':
             if (isset($this->headers['host'])) {
                 return trim($this->headers['host']);
             }
             if ($this->_proxy !== null) {
                 return $this->_proxy;
             }
             if ($this->_uri !== null) {
                 $host = $this->_uri->getHost();
                 if (($port = $this->_uri->getPort()) !== false) {
                     $host .= ':' . $port;
                 }
             }
             return $host;
         case 'port':
             $port = $this->_uri->getPort();
             if (!is_numeric($port)) {
                 return $this->isSecure() ? 443 : 80;
             }
             return $port;
         case 'connection':
             if ($this->_connection === null) {
                 include_once 'HTTP/Connection.php';
                 $this->_connection = HTTP_Connection::factory('Socket');
             }
             return $this->_connection;
         default:
             return parent::__get($property);
     }
 }
开发者ID:baijnath-sag,项目名称:izi-sandbox,代码行数:65,代码来源:Request2.php

示例4: testHostAndPort

 /**
  * test that an authority containing host and port maps to expected host and port
  *
  * This is also a regression test to test that using ip-literals works along-
  * side ipv4 and reg-name hosts incl. port numbers
  *
  * It was reported as Bug #20423 on 2014-10-06 18:25 UTC that
  * http://[::1]// URI drops the host
  *
  * @param string      $authority    string
  * @param string      $expectedHost string
  * @param string|bool $expectedPort string or FALSE
  *
  * @return void
  * @dataProvider provideHostAndPort
  * @covers       Net_URL2::setAuthority()
  * @link         https://pear.php.net/bugs/bug.php?id=20423
  * @link         http://tools.ietf.org/html/rfc3986#section-3.2.2
  * @link         http://tools.ietf.org/html/rfc3986#section-3.2
  * @link         http://tools.ietf.org/html/rfc3986#section-3.2.3
  */
 public function testHostAndPort($authority, $expectedHost, $expectedPort)
 {
     $uri = "http://{$authority}";
     $url = new Net_URL2($uri);
     $this->assertSame($expectedHost, $url->getHost());
     $this->assertSame($expectedPort, $url->getPort());
 }
开发者ID:rafalwojciechowski,项目名称:news,代码行数:28,代码来源:URL2Test.php


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