本文整理汇总了PHP中Net_URL2::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Net_URL2::getUser方法的具体用法?PHP Net_URL2::getUser怎么用?PHP Net_URL2::getUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Net_URL2
的用法示例。
在下文中一共展示了Net_URL2::getUser方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetEmptyAuthority
/**
* Tests setting a zero-length string and false as authority
* Also: Regression test for Bug #20420
*
* @covers Net_URL2::setAuthority
* @return void
* @link https://pear.php.net/bugs/bug.php?id=20420
*/
public function testSetEmptyAuthority()
{
$url = new Net_URL2('http://www.example.com/');
$url->setAuthority('');
$this->assertSame('', $url->getAuthority());
$this->assertSame('', $url->getHost());
$this->assertSame(false, $url->getPort());
$this->assertSame(false, $url->getUserinfo());
$this->assertSame(false, $url->getUser());
$url->setAuthority(false);
$this->assertSame(false, $url->getAuthority());
}
示例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;
}
示例3: setUrl
/**
* Sets the URL for this request
*
* If the URL has userinfo part (username & password) these will be removed
* and converted to auth data. If the URL does not have a path component,
* that will be set to '/'.
*
* @param string|Net_URL2 Request URL
* @return HTTP_Request2
* @throws HTTP_Request2_LogicException
*/
public function setUrl($url)
{
if (is_string($url)) {
$url = new Net_URL2($url, array(Net_URL2::OPTION_USE_BRACKETS => $this->config['use_brackets']));
}
if (!$url instanceof Net_URL2) {
throw new HTTP_Request2_LogicException('Parameter is not a valid HTTP URL', HTTP_Request2_Exception::INVALID_ARGUMENT);
}
// URL contains username / password?
if ($url->getUserinfo()) {
$username = $url->getUser();
$password = $url->getPassword();
$this->setAuth(rawurldecode($username), $password ? rawurldecode($password) : '');
$url->setUserinfo('');
}
if ('' == $url->getPath()) {
$url->setPath('/');
}
$this->url = $url;
return $this;
}
示例4: setUrl
/**
* Sets the URL for this request
*
* If the URL has userinfo part (username & password) these will be removed
* and converted to auth data. If the URL does not have a path component,
* that will be set to '/'.
*
* @param string|Net_URL2 Request URL
* @return HTTP_Request2
* @throws HTTP_Request2_Exception
*/
public function setUrl($url)
{
if (is_string($url)) {
$url = new Net_URL2($url);
}
if (!$url instanceof Net_URL2) {
throw new HTTP_Request2_Exception('Parameter is not a valid HTTP URL');
}
// URL contains username / password?
if ($url->getUserinfo()) {
$username = $url->getUser();
$password = $url->getPassword();
$this->setAuth(rawurldecode($username), $password ? rawurldecode($password) : '');
$url->setUserinfo('');
}
if ('' == $url->getPath()) {
$url->setPath('/');
}
$this->url = $url;
return $this;
}