private function prepare($mimeType, $baseName)
    {
        // Ensure that output buffering is turned off. @ - intentionally
        @ob_end_clean();

        // Special hack for legacy IE version
        if (ini_get('zlib.output_compression')) {
            ini_set('zlib.output_compression', 'Off');
        }

        // Prepare required headers
        $headers = array(
            'Content-Type' => $mimeType,
            'Content-Disposition' => sprintf('attachment; filename="%s"', rawurldecode($baseName)),
            'Content-Transfer-Encoding' => 'binary',
            'Accept-Ranges' => 'bytes',
            'Cache-control' => 'private',
            'Pragma' => 'private',
            'Expires' => 'Thu, 21 Jul 1999 05:00:00 GMT'
        );

        $this->headerBag->appendPairs($headers)
                        ->send()
                        ->clear();
    }