protected function prepareResponse($data, $code)
    {
        $rawHeaders = array();
        $rawContent = null;
        
        $lines = preg_split('/(\\r?\\n)/', $data, -1, PREG_SPLIT_DELIM_CAPTURE);
        for ($i = 0, $count = count($lines); $i < $count; $i += 2) {
            $line = $lines[$i];

            if (!empty($line)) {
                $rawHeaders[] = $line;
            } else {
                $rawContent = implode('', array_slice($lines, $i + 2));
                break;
            }
        }
        
        $headers = $this->prepareHeaders($rawHeaders);

        return new Response($rawContent, $code, $headers);
    }