mirror of
https://github.com/getformwork/formwork.git
synced 2025-02-22 16:56:50 +01:00
Use Header::make()
for complicated headers
This commit is contained in:
parent
0c91f35119
commit
72b43d084d
@ -3,6 +3,7 @@
|
||||
namespace Formwork\Response;
|
||||
|
||||
use Formwork\Utils\FileSystem;
|
||||
use Formwork\Utils\Header;
|
||||
use Formwork\Utils\HTTPResponse;
|
||||
|
||||
class FileResponse extends Response
|
||||
@ -14,7 +15,7 @@ class FileResponse extends Response
|
||||
{
|
||||
$headers += [
|
||||
'Content-Type' => FileSystem::mimeType($path),
|
||||
'Content-Disposition' => $download ? 'attachment; filename="' . basename($path) . '"' : 'inline',
|
||||
'Content-Disposition' => !$download ? 'inline' : Header::make(['attachment', 'filename' => basename($path)]),
|
||||
'Content-Length' => FileSystem::fileSize($path)
|
||||
];
|
||||
parent::__construct(FileSystem::read($path), $status, $headers);
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace Formwork\Response;
|
||||
|
||||
use Formwork\Parsers\JSON;
|
||||
use Formwork\Utils\Header;
|
||||
|
||||
class JSONResponse extends Response
|
||||
{
|
||||
@ -12,7 +13,7 @@ class JSONResponse extends Response
|
||||
public function __construct(array $data, int $status = 200, array $headers = [])
|
||||
{
|
||||
$headers += [
|
||||
'Content-Type' => 'application/json; charset=utf-8'
|
||||
'Content-Type' => Header::make(['application/json', 'charset' => 'utf-8'])
|
||||
];
|
||||
parent::__construct(JSON::encode($data), $status, $headers);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user