httpResponse = $response; $this->stream = $response->getBody(); } /** * @param string $name * @return null | string */ public function getHeader($name) { $values = $this->httpResponse->getHeader($name); if (empty($values)) { return null; } else { return $values[0]; } } /** * @param string $name * @return float */ public function getHeaderAsLong($name) { $values = $this->httpResponse->getHeader($name); if (empty($values)) { return -1; } else { return floatval($values[0]); } } /** * @param $name * @return DateTime|null */ public function getHeaderAsRFC822Date($name) { $values = $this->httpResponse->getHeader($name); if (empty($values)) { return null; } else { try { return DateUtils::parseRfc822Date($values[0]); } catch (Exception $e) { self::$logger->warning('Invalid '.$name.':'.$values[0]); } } } /** * @return StreamInterface */ public function getContent() { return $this->stream; } /** * @return string */ public function readContent() { if (isset($this->content)) { return $this->content; } $this->content = $this->stream->__toString(); $this->stream->close(); return $this->content; } /** * @return int */ public function getStatusCode() { return $this->httpResponse->getStatusCode(); } /** * @return string */ public function getStatusText() { return implode(' ', [ $this->httpResponse->getProtocolVersion(), $this->httpResponse->getStatusCode(), $this->httpResponse->getReasonPhrase(), ]); } } YopHttpResponse::__init();