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


PHP HttpResponse::reset方法代码示例

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


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

示例1: finish

 /** 	
  * @param string $type NORMAL, BROKEN, TIMEOUT
  */
 public function finish($type = 'NORMAL')
 {
     $this->finished = true;
     if ($type === 'BROKEN') {
         $this->res->error = HttpConn::getLastError();
     } else {
         if ($type !== 'NORMAL') {
             $this->res->error = ucfirst(strtolower($type));
         }
     }
     // gzip decode
     $encoding = $this->res->getHeader('content-encoding');
     if ($encoding !== null && strstr($encoding, 'gzip')) {
         $this->res->body = HttpClient::gzdecode($this->res->body);
     }
     // parser
     $this->res->timeCost = microtime(true) - $this->timeBegin;
     $this->cli->runParser($this->res, $this->req, $this->key);
     // conn
     if ($this->conn) {
         // close conn
         $close = $this->res->getHeader('connection');
         $this->conn->close($type !== 'NORMAL' || !strcasecmp($close, 'close'));
         $this->conn = null;
         // redirect
         if (($this->res->status === 301 || $this->res->status === 302) && $this->res->numRedirected < $this->req->getMaxRedirect() && ($location = $this->res->getHeader('location')) !== null) {
             HttpClient::debug('redirect to \'', $location, '\'');
             $req = $this->req;
             if (!preg_match('/^https?:\\/\\//i', $location)) {
                 $pa = $req->getUrlParams();
                 $url = $pa['scheme'] . '://' . $pa['host'];
                 if (isset($pa['port'])) {
                     $url .= ':' . $pa['port'];
                 }
                 if (substr($location, 0, 1) == '/') {
                     $url .= $location;
                 } else {
                     $url .= substr($pa['path'], 0, strrpos($pa['path'], '/') + 1) . $location;
                 }
                 $location = $url;
                 /// FIXME: strip relative '../../'
             }
             // change new url
             $prevUrl = $req->getUrl();
             $req->setUrl($location);
             if (!$req->getHeader('referer')) {
                 $req->setHeader('referer', $prevUrl);
             }
             if ($req->getMethod() !== 'HEAD') {
                 $req->setMethod('GET');
             }
             $req->clearCookie();
             $req->setHeader('host', null);
             $req->setHeader('x-server-ip', null);
             // reset response
             $this->res->numRedirected++;
             $this->finished = $this->headerOK = false;
             return $this->res->reset();
         }
     }
     HttpClient::debug('finished', $this->res->hasError() ? ' (' . $this->res->error . ')' : '');
     $this->req = $this->cli = null;
 }
开发者ID:sophia2152,项目名称:pspider,代码行数:66,代码来源:HttpClient.class.php


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