Skip to content
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.

Commit

Permalink
stream are not send as attachment by default anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
Joan Fabrégat committed Mar 2, 2018
1 parent 1690f2b commit e898b93
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codeinchq/lib-psr7responses",
"version": "1.1.2",
"version": "1.1.3",
"description": "A collection of PSR-7 responses",
"homepage": "https://github.com/codeinchq/lib-psr7responses",
"type": "library",
Expand Down
4 changes: 2 additions & 2 deletions src/FileResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ class FileResponse extends StreamResponse {
* @param string $filePath
* @param null|string $fileName
* @param null|string $mimeType
* @param bool|null $asAttachment
* @param bool $asAttachment
* @param int $status
* @param array $headers
* @param string $version
* @param null|string $reason
* @throws ResponseException
*/
public function __construct(string $filePath, ?string $fileName = null, ?string $mimeType = null,
?bool $asAttachment = null, int $status = 200, array $headers = [],
bool $asAttachment = true, int $status = 200, array $headers = [],
string $version = '1.1', ?string $reason = null)
{
if (!is_file($filePath)) {
Expand Down
11 changes: 5 additions & 6 deletions src/StreamResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
namespace CodeInc\Psr7Responses;
use GuzzleHttp\Psr7\Response;
use function GuzzleHttp\Psr7\stream_for;
use Psr\Http\Message\StreamInterface;


/**
Expand All @@ -36,24 +35,24 @@ class StreamResponse extends Response {
/**
* StreamResponse constructor.
*
* @param resource|string|null|int|float|bool|StreamInterface|callable $resource
* @param null|string $fileName
* @param $resource
* @param null|string $mimeType
* @param int|null $contentLength
* @param bool|null $asAttachment
* @param null|string $fileName
* @param bool $asAttachment
* @param int $status
* @param array $headers
* @param string $version
* @param null|string $reason
*/
public function __construct($resource, ?string $mimeType = null, ?int $contentLength = null,
?string $fileName = null, ?bool $asAttachment = null, int $status = 200, array $headers = [],
?string $fileName = null, bool $asAttachment = false, int $status = 200, array $headers = [],
string $version = '1.1', ?string $reason = null)
{
if ($mimeType) {
$headers["Content-Type"] = $mimeType;
}
$headers["Content-Disposition"] = $asAttachment !== false ? "attachment" : "inline";
$headers["Content-Disposition"] = $asAttachment ? "attachment" : "inline";
if ($fileName) {
$headers["Content-Disposition"] .= sprintf("; filename=\"%s\"", $fileName);
}
Expand Down

0 comments on commit e898b93

Please sign in to comment.