public function getHeaders(ResponseBag $bag) { if (!$bag->has(self::FILENAME)) { throw new \Exception('Missing filename for streamed response'); } $bag->addHeader('X-Sendfile', $bag->get(self::FILENAME)); $bag->addHeader('X-Accel-Buffering', 'no'); $bag->addHeader('Transfer-Encoding', 'chunked'); $bag->addHeader('Content-Type', 'application/force-download'); $bag->addHeader('Content-Disposition', sprintf('%s; filename="%s"', $bag->get(self::ATTACHMENT_DISPOSITION, 'attachment'), $bag->get(self::FILENAME))); return $bag->getHeaders(); }