From a045d496b684dffdce7f69e6e474109a0b7b2ece Mon Sep 17 00:00:00 2001 From: Sander-Toonen Date: Wed, 31 Dec 2014 11:59:18 +0100 Subject: [PATCH 1/2] [HttpFoundation] Added the ability of mapping stream wrapper protocols when using X-Sendfile --- src/Symfony/Component/HttpFoundation/BinaryFileResponse.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php index 5ad588bbb8cdd..bceaf6fe0d7a1 100644 --- a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php +++ b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php @@ -189,6 +189,10 @@ public function prepare(Request $request) // Use X-Sendfile, do not send any content. $type = $request->headers->get('X-Sendfile-Type'); $path = $this->file->getRealPath(); + // Fall back to scheme://path for stream wrapped locations. + if (empty($path)) { + $path = $this->file->getPathname(); + } if (strtolower($type) == 'x-accel-redirect') { // Do X-Accel-Mapping substitutions. foreach (explode(',', $request->headers->get('X-Accel-Mapping', '')) as $mapping) { From 0798003a7a0c21e0fabe8dfdb9200778921b1810 Mon Sep 17 00:00:00 2001 From: Sander Toonen Date: Wed, 31 Dec 2014 13:20:21 +0100 Subject: [PATCH 2/2] Fix indentation --- src/Symfony/Component/HttpFoundation/BinaryFileResponse.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php index bceaf6fe0d7a1..e74cc23d0a4a7 100644 --- a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php +++ b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php @@ -191,7 +191,7 @@ public function prepare(Request $request) $path = $this->file->getRealPath(); // Fall back to scheme://path for stream wrapped locations. if (empty($path)) { - $path = $this->file->getPathname(); + $path = $this->file->getPathname(); } if (strtolower($type) == 'x-accel-redirect') { // Do X-Accel-Mapping substitutions.