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


PHP Net_URL2::__toString方法代码示例

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


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

示例1: send

 /**
  * Sends the request and returns the response
  *
  * @throws   HTTP_Request2_Exception
  * @return   HTTP_Request2_Response
  */
 public function send()
 {
     // Sanity check for URL
     if (!$this->url instanceof Net_URL2 || !$this->url->isAbsolute() || !in_array(strtolower($this->url->getScheme()), array('https', 'http'))) {
         throw new HTTP_Request2_LogicException('HTTP_Request2 needs an absolute HTTP(S) request URL, ' . ($this->url instanceof Net_URL2 ? "'" . $this->url->__toString() . "'" : 'none') . ' given', HTTP_Request2_Exception::INVALID_ARGUMENT);
     }
     if (empty($this->adapter)) {
         $this->setAdapter($this->getConfig('adapter'));
     }
     // magic_quotes_runtime may break file uploads and chunked response
     // processing; see bug #4543. Don't use ini_get() here; see bug #16440.
     if ($magicQuotes = get_magic_quotes_runtime()) {
         set_magic_quotes_runtime(false);
     }
     // force using single byte encoding if mbstring extension overloads
     // strlen() and substr(); see bug #1781, bug #10605
     if (extension_loaded('mbstring') && 2 & ini_get('mbstring.func_overload')) {
         $oldEncoding = mb_internal_encoding();
         mb_internal_encoding('8bit');
     }
     try {
         $response = $this->adapter->sendRequest($this);
     } catch (Exception $e) {
     }
     // cleanup in either case (poor man's "finally" clause)
     if ($magicQuotes) {
         set_magic_quotes_runtime(true);
     }
     if (!empty($oldEncoding)) {
         mb_internal_encoding($oldEncoding);
     }
     // rethrow the exception
     if (!empty($e)) {
         throw $e;
     }
     return $response;
 }
开发者ID:OPIN-CA,项目名称:w3c_validator,代码行数:43,代码来源:Request2.php

示例2: handleRedirect

 /**
  * Handles HTTP redirection
  *
  * This method will throw an Exception if redirect to a non-HTTP(S) location
  * is attempted, also if number of redirects performed already is equal to
  * 'max_redirects' configuration parameter.
  *
  * @param    HTTP_Request2               Original request
  * @param    HTTP_Request2_Response      Response containing redirect
  * @return   HTTP_Request2_Response      Response from a new location
  * @throws   HTTP_Request2_Exception
  */
 protected function handleRedirect(HTTP_Request2 $request, HTTP_Request2_Response $response)
 {
     if (is_null($this->redirectCountdown)) {
         $this->redirectCountdown = $request->getConfig('max_redirects');
     }
     if (0 == $this->redirectCountdown) {
         $this->redirectCountdown = null;
         // Copying cURL behaviour
         throw new HTTP_Request2_MessageException('Maximum (' . $request->getConfig('max_redirects') . ') redirects followed', HTTP_Request2_Exception::TOO_MANY_REDIRECTS);
     }
     $redirectUrl = new Net_URL2($response->getHeader('location'), array(Net_URL2::OPTION_USE_BRACKETS => $request->getConfig('use_brackets')));
     // refuse non-HTTP redirect
     if ($redirectUrl->isAbsolute() && !in_array($redirectUrl->getScheme(), array('http', 'https'))) {
         $this->redirectCountdown = null;
         throw new HTTP_Request2_MessageException('Refusing to redirect to a non-HTTP URL ' . $redirectUrl->__toString(), HTTP_Request2_Exception::NON_HTTP_REDIRECT);
     }
     // Theoretically URL should be absolute (see http://tools.ietf.org/html/rfc2616#section-14.30),
     // but in practice it is often not
     if (!$redirectUrl->isAbsolute()) {
         $redirectUrl = $request->getUrl()->resolve($redirectUrl);
     }
     $redirect = clone $request;
     $redirect->setUrl($redirectUrl);
     if (303 == $response->getStatus() || !$request->getConfig('strict_redirects') && in_array($response->getStatus(), array(301, 302))) {
         $redirect->setMethod(HTTP_Request2::METHOD_GET);
         $redirect->setBody('');
     }
     if (0 < $this->redirectCountdown) {
         $this->redirectCountdown--;
     }
     return $this->sendRequest($redirect);
 }
开发者ID:verbazend,项目名称:AWFA,代码行数:44,代码来源:Socket.php

示例3: testExampleUri

 /**
  * test that Net_URL2 works with the example URIs from RFC 3986 Section 1.1.2
  *
  * @param string $uri example URI
  *
  * @return       void
  * @dataProvider provideExampleUri
  * @link         http://tools.ietf.org/html/rfc3986#section-1.1.2
  * @see          testComponentRecompositionAndNormalization
  */
 public function testExampleUri($uri)
 {
     $url = new Net_URL2($uri);
     $this->assertSame($uri, $url->__toString());
     $url->normalize();
     $this->assertSame($uri, $url->__toString());
 }
开发者ID:rafalwojciechowski,项目名称:news,代码行数:17,代码来源:URL2Test.php


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