public function getCode()
    {
        if (is_null($this->code)) {
            $code = 0;
            if (!empty($this->headers)) {
                foreach ($this->headers as $header) {
                    $matches = array();
                    preg_match('|HTTP/\d(\.\d)?\s+(\d+)(\s+.*)?|', $header, $matches);
                    if (isset($matches[2])) {
                        $code = (int)$matches[2];
                    }
                }
            }
            $this->code = $code;
        }
        return $this->code;
    }