Skip to content

Commit 96e44d9

Browse files
Jason FunkJason Funk
Jason Funk
authored and
Jason Funk
committed
Allow the developer to set the Content-Disposition header in Response::download()
1 parent cffded6 commit 96e44d9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

laravel/response.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,14 @@ public static function download($path, $name = null, $headers = array())
202202
// off to the HttpFoundation and let it create the header text.
203203
$response = new static(File::get($path), 200, $headers);
204204

205-
$d = $response->disposition($name);
205+
// If the Content-Disposition header has already been set by the
206+
// merge above, then do not override it with out generated one.
207+
if (!isset($headers['Content-Disposition'])) {
208+
$d = $response->disposition($name);
209+
$response = $response->header('Content-Disposition', $d);
210+
}
206211

207-
return $response->header('Content-Disposition', $d);
212+
return $response;
208213
}
209214

210215
/**

0 commit comments

Comments
 (0)