url === '') { throw new \LogicException('The URL is missing'); } Logging::log('Fetch URL: '.$this->url); Logging::log('Etag: '.$this->etag); Logging::log('Last-Modified: '.$this->last_modified); $response = $this->doRequest(); if (is_array($response)) { if ($response['status'] == 304) { $this->is_modified = false; } else { $this->etag = isset($response['headers']['ETag']) ? $response['headers']['ETag'] : ''; $this->last_modified = isset($response['headers']['Last-Modified']) ? $response['headers']['Last-Modified'] : ''; $this->content = $response['body']; } } } public function parseHeaders(array $lines) { $status = 200; $headers = array(); foreach ($lines as $line) { if (strpos($line, 'HTTP') === 0 && strpos($line, '301') === false && strpos($line, '302') === false) { $status = (int) substr($line, 9, 3); } else if (strpos($line, ':') !== false) { @list($name, $value) = explode(': ', $line); if ($value) $headers[trim($name)] = trim($value); } } Logging::log('HTTP status code: '.$status); foreach ($headers as $name => $value) { Logging::log('HTTP headers: '.$name.' => '.$value); } return array($status, $headers); } public function setLastModified($last_modified) { $this->last_modified = $last_modified; return $this; } public function getLastModified() { return $this->last_modified; } public function setEtag($etag) { $this->etag = $etag; return $this; } public function getEtag() { return $this->etag; } public function getUrl() { return $this->url; } public function getContent() { return $this->content; } public function isModified() { return $this->is_modified; } }