public function __construct($status_code, $body, array $headers)
 {
     if (strlen($body) > 512) {
         $excerpt = substr($body, 0, 512) . '...';
     } else {
         $excerpt = $body;
     }
     $content_type = BaseHTTPFuture::getHeader($headers, 'Content-Type');
     $match = null;
     if (preg_match('/;\\s*charset=([^;]+)/', $content_type, $match)) {
         $encoding = trim($match[1], "\"'");
         try {
             $excerpt = Utf8::phutil_utf8_convert($excerpt, 'UTF-8', $encoding);
         } catch (Exception $ex) {
         }
     }
     $this->excerpt = Utf8::phutil_utf8ize($excerpt);
     parent::__construct($status_code);
 }
Beispiel #2
0
 public function setURI($uri)
 {
     $url_processor = new UrlProcessor($uri);
     $url_processor->validateForHttpFuture();
     $parts = $url_processor->getUrlParts();
     $this->host = $parts['host'];
     if (!empty($parts['port'])) {
         $this->port = $parts['port'];
     }
     if (isset($parts['user']) || isset($parts['pass'])) {
         throw new Exception("HTTP Basic Auth is not supported by HTTPFuture.");
     }
     if (isset($parts['path'])) {
         $this->fullRequestPath = $parts['path'];
     } else {
         $this->fullRequestPath = '/';
     }
     if (isset($parts['query'])) {
         $this->fullRequestPath .= '?' . $parts['query'];
     }
     return parent::setURI($uri);
 }