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


PHP HTTP_Request2_Response::isRedirect方法代码示例

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


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

示例1: callbackWriteHeader

 /**
  * Callback function called by cURL for saving the response headers
  *
  * @param    resource    cURL handle
  * @param    string      response header (with trailing CRLF)
  * @return   integer     number of bytes saved
  * @see      HTTP_Request2_Response::parseHeaderLine()
  */
 protected function callbackWriteHeader($ch, $string)
 {
     // we may receive a second set of headers if doing e.g. digest auth
     if ($this->eventReceivedHeaders || !$this->eventSentHeaders) {
         // don't bother with 100-Continue responses (bug #15785)
         if (!$this->eventSentHeaders || $this->response->getStatus() >= 200) {
             $this->request->setLastEvent('sentHeaders', curl_getinfo($ch, CURLINFO_HEADER_OUT));
         }
         $upload = curl_getinfo($ch, CURLINFO_SIZE_UPLOAD);
         // if body wasn't read by a callback, send event with total body size
         if ($upload > $this->position) {
             $this->request->setLastEvent('sentBodyPart', $upload - $this->position);
             $this->position = $upload;
         }
         if ($upload && (!$this->eventSentHeaders || $this->response->getStatus() >= 200)) {
             $this->request->setLastEvent('sentBody', $upload);
         }
         $this->eventSentHeaders = true;
         // we'll need a new response object
         if ($this->eventReceivedHeaders) {
             $this->eventReceivedHeaders = false;
             $this->response = null;
         }
     }
     if (empty($this->response)) {
         $this->response = new HTTP_Request2_Response($string, false);
     } else {
         $this->response->parseHeaderLine($string);
         if ('' == trim($string)) {
             // don't bother with 100-Continue responses (bug #15785)
             if (200 <= $this->response->getStatus()) {
                 $this->request->setLastEvent('receivedHeaders', $this->response);
             }
             if ($this->request->getConfig('follow_redirects') && $this->response->isRedirect()) {
                 $redirectUrl = new Net_URL2($this->response->getHeader('location'));
                 // for versions lower than 5.2.10, check the redirection URL protocol
                 if (!defined('CURLOPT_REDIR_PROTOCOLS') && $redirectUrl->isAbsolute() && !in_array($redirectUrl->getScheme(), array('http', 'https'))) {
                     return -1;
                 }
                 if ($jar = $this->request->getCookieJar()) {
                     $jar->addCookiesFromResponse($this->response, $this->request->getUrl());
                     if (!$redirectUrl->isAbsolute()) {
                         $redirectUrl = $this->request->getUrl()->resolve($redirectUrl);
                     }
                     if ($cookies = $jar->getMatching($redirectUrl, true)) {
                         curl_setopt($ch, CURLOPT_COOKIE, $cookies);
                     }
                 }
             }
             $this->eventReceivedHeaders = true;
         }
     }
     return strlen($string);
 }
开发者ID:venamax,项目名称:trixandtrax-cl,代码行数:62,代码来源:Curl.php


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