headers['Http-Version'] = $matches[1]; $this->headers['Status-Code'] = $matches[2]; $this->headers['Status'] = $matches[2].' '.$matches[3]; # Convert headers into an associative array foreach ($headers as $header) { preg_match('#(.*?)\:\s(.*)#', $header, $matches); $this->headers[$matches[1]] = $matches[2]; } # Remove the headers from the response body $this->body = preg_replace($pattern, '', $response); } public function __toString() { return $this->body; } public function headers(){ return $this->headers; } }