Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
2276c670
Commit
2276c670
authored
Apr 02, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use http foundation to create content-disposition headers.
parent
8e80756b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
2 deletions
+25
-2
response.php
laravel/response.php
+25
-2
No files found.
laravel/response.php
View file @
2276c670
<?php
namespace
Laravel
;
<?php
namespace
Laravel
;
use
Symfony\Component\HttpFoundation\ResponseHeaderBag
;
use
Symfony\Component\HttpFoundation\Response
as
FoundationResponse
;
use
Symfony\Component\HttpFoundation\Response
as
FoundationResponse
;
class
Response
{
class
Response
{
...
@@ -121,10 +122,12 @@ class Response {
...
@@ -121,10 +122,12 @@ class Response {
{
{
if
(
is_null
(
$name
))
$name
=
basename
(
$path
);
if
(
is_null
(
$name
))
$name
=
basename
(
$path
);
// We'll set some sensible default headers, but merge the array given to
// us so that the developer has the chance to override any of these
// default headers with header values of their own liking.
$headers
=
array_merge
(
array
(
$headers
=
array_merge
(
array
(
'Content-Description'
=>
'File Transfer'
,
'Content-Description'
=>
'File Transfer'
,
'Content-Type'
=>
File
::
mime
(
File
::
extension
(
$path
)),
'Content-Type'
=>
File
::
mime
(
File
::
extension
(
$path
)),
'Content-Disposition'
=>
'attachment; filename="'
.
$name
.
'"'
,
'Content-Transfer-Encoding'
=>
'binary'
,
'Content-Transfer-Encoding'
=>
'binary'
,
'Expires'
=>
0
,
'Expires'
=>
0
,
'Cache-Control'
=>
'must-revalidate, post-check=0, pre-check=0'
,
'Cache-Control'
=>
'must-revalidate, post-check=0, pre-check=0'
,
...
@@ -132,7 +135,27 @@ class Response {
...
@@ -132,7 +135,27 @@ class Response {
'Content-Length'
=>
File
::
size
(
$path
),
'Content-Length'
=>
File
::
size
(
$path
),
),
$headers
);
),
$headers
);
return
new
static
(
File
::
get
(
$path
),
200
,
$headers
);
// Once we create the response, we need to set the content disposition
// header on the response based on the file's name. We'll pass this
// off to the HttpFoundation and let it create the header text.
$response
=
new
static
(
File
::
get
(
$path
),
200
,
$headers
);
$d
=
$response
->
disposition
(
$name
);
return
$response
->
header
(
'Content-Disposition'
,
$d
);
}
/**
* Create the proper Content-Disposition header.
*
* @param string $file
* @return string
*/
public
function
disposition
(
$file
)
{
$type
=
ResponseHeaderBag
::
DISPOSITION_ATTACHMENT
;
return
$this
->
foundation
->
headers
->
makeDisposition
(
$type
,
$file
);
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment