Commit 0b489692 by sadgnome Committed by Qiang Xue

Fixed content-length in sendContentAsFile()

Fixed wrong Content-Length header when sending file using Response::sendContentAsFile().
parent bdee46d1
...@@ -475,9 +475,6 @@ class Response extends \yii\base\Response ...@@ -475,9 +475,6 @@ class Response extends \yii\base\Response
throw new HttpException(416, 'Requested range not satisfiable'); throw new HttpException(416, 'Requested range not satisfiable');
} }
$mimeType = isset($options['mimeType']) ? $options['mimeType'] : 'application/octet-stream';
$this->setDownloadHeaders($attachmentName, $mimeType, !empty($options['inline']), $contentLength);
list($begin, $end) = $range; list($begin, $end) = $range;
if ($begin != 0 || $end != $contentLength - 1) { if ($begin != 0 || $end != $contentLength - 1) {
$this->setStatusCode(206); $this->setStatusCode(206);
...@@ -488,6 +485,9 @@ class Response extends \yii\base\Response ...@@ -488,6 +485,9 @@ class Response extends \yii\base\Response
$this->content = $content; $this->content = $content;
} }
$mimeType = isset($options['mimeType']) ? $options['mimeType'] : 'application/octet-stream';
$this->setDownloadHeaders($attachmentName, $mimeType, !empty($options['inline']), $end - $begin + 1);
$this->format = self::FORMAT_RAW; $this->format = self::FORMAT_RAW;
return $this; return $this;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment