Skip to content

Commit b65742d

Browse files
committed
Merge branch '6.4' into 7.1
* 6.4: fix merge [Intl] Update ICU data from 74.1 to 75.1 use DeprecatedCallableInfo for Twig callables if possible [Filesystem] Add a warning about `chown()` and `chgrp()` on Windows [String] Update wcswidth data with Unicode 16 PhpSubprocess: Add flag PREG_OFFSET_CAPTURE to preg_match to identify the offset Work around parse_url() bug [Ldap] Clean `ldap_connect()` call in `LdapTestCase` [HttpFoundation] Update links for X-Accel-Redirect and fail properly when X-Accel-Mapping is missing
2 parents 92ab8d3 + 3bd4a26 commit b65742d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

BinaryFileResponse.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,12 @@ public function prepare(Request $request): static
218218
}
219219
if ('x-accel-redirect' === strtolower($type)) {
220220
// Do X-Accel-Mapping substitutions.
221-
// @link https://www.nginx.com/resources/wiki/start/topics/examples/x-accel/#x-accel-redirect
222-
$parts = HeaderUtils::split($request->headers->get('X-Accel-Mapping', ''), ',=');
221+
// @link https://github.com/rack/rack/blob/main/lib/rack/sendfile.rb
222+
// @link https://mattbrictson.com/blog/accelerated-rails-downloads
223+
if (!$request->headers->has('X-Accel-Mapping')) {
224+
throw new \LogicException('The "X-Accel-Mapping" header must be set when "X-Sendfile-Type" is set to "X-Accel-Redirect".');
225+
}
226+
$parts = HeaderUtils::split($request->headers->get('X-Accel-Mapping'), ',=');
223227
foreach ($parts as $part) {
224228
[$pathPrefix, $location] = $part;
225229
if (str_starts_with($path, $pathPrefix)) {

Request.php

+1
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ public static function create(string $uri, string $method = 'GET', array $parame
302302
if (false === $components) {
303303
throw new \InvalidArgumentException(sprintf('Malformed URI "%s".', $uri));
304304
}
305+
305306
if (isset($components['host'])) {
306307
$server['SERVER_NAME'] = $components['host'];
307308
$server['HTTP_HOST'] = $components['host'];

0 commit comments

Comments
 (0)