🔧
This commit is contained in:
@@ -45,7 +45,7 @@ class BinaryFileResponse extends Response
|
||||
* @param bool $autoEtag Whether the ETag header should be automatically set
|
||||
* @param bool $autoLastModified Whether the Last-Modified header should be automatically set
|
||||
*/
|
||||
public function __construct(\SplFileInfo|string $file, int $status = 200, array $headers = [], bool $public = true, string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true)
|
||||
public function __construct(\SplFileInfo|string $file, int $status = 200, array $headers = [], bool $public = true, ?string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true)
|
||||
{
|
||||
parent::__construct(null, $status, $headers);
|
||||
|
||||
@@ -63,7 +63,7 @@ class BinaryFileResponse extends Response
|
||||
*
|
||||
* @throws FileException
|
||||
*/
|
||||
public function setFile(\SplFileInfo|string $file, string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true): static
|
||||
public function setFile(\SplFileInfo|string $file, ?string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true): static
|
||||
{
|
||||
if (!$file instanceof File) {
|
||||
if ($file instanceof \SplFileInfo) {
|
||||
@@ -217,8 +217,12 @@ class BinaryFileResponse extends Response
|
||||
}
|
||||
if ('x-accel-redirect' === strtolower($type)) {
|
||||
// Do X-Accel-Mapping substitutions.
|
||||
// @link https://www.nginx.com/resources/wiki/start/topics/examples/x-accel/#x-accel-redirect
|
||||
$parts = HeaderUtils::split($request->headers->get('X-Accel-Mapping', ''), ',=');
|
||||
// @link https://github.com/rack/rack/blob/main/lib/rack/sendfile.rb
|
||||
// @link https://mattbrictson.com/blog/accelerated-rails-downloads
|
||||
if (!$request->headers->has('X-Accel-Mapping')) {
|
||||
throw new \LogicException('The "X-Accel-Mapping" header must be set when "X-Sendfile-Type" is set to "X-Accel-Redirect".');
|
||||
}
|
||||
$parts = HeaderUtils::split($request->headers->get('X-Accel-Mapping'), ',=');
|
||||
foreach ($parts as $part) {
|
||||
[$pathPrefix, $location] = $part;
|
||||
if (str_starts_with($path, $pathPrefix)) {
|
||||
|
||||
Reference in New Issue
Block a user