private function readHeader() { // read header while (($line = $this->conn->getLine()) !== null) { if ($line === false) { return $this->finish('BROKEN'); } if ($line === '') { $this->headerOK = true; $this->chunkLeft = 0; return $this->readBody(); } HttpClient::debug('read header line: ', $line); if (!strncmp('HTTP/', $line, 5)) { $line = trim(substr($line, strpos($line, ' '))); list($this->res->status, $this->res->statusText) = explode(' ', $line, 2); $this->res->status = intval($this->res->status); } else { if (!strncasecmp('Set-Cookie: ', $line, 12)) { $cookie = $this->parseCookieLine($line); if ($cookie !== false) { $this->res->setRawCookie($cookie['name'], $cookie['value']); $this->cli->setRawCookie($cookie['name'], $cookie['value'], $cookie['expires'], $cookie['domain'], $cookie['path']); } } else { list($k, $v) = explode(':', $line, 2); $this->res->addHeader($k, trim($v)); } } } }