Skip to content

Commit

Permalink
Update ResponseFactory.php
Browse files Browse the repository at this point in the history
  • Loading branch information
mevdschee authored Jul 2, 2020
1 parent 1db476a commit 81a20f1
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions src/Tqdev/PhpCrudApi/ResponseFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,7 @@ public static function fromObject(int $status, $body): ResponseInterface
return self::from($status, 'application/json', $content);
}

public static function fromFile(int $status, string $filename): ResponseInterface
{
$psr17Factory = new Psr17Factory();
$response = $psr17Factory->createResponse($status);
$stream = $psr17Factory->createStreamFromFile($filename);
$response = $response->withBody($stream);
$response = $response->withHeader('Content-Type', mime_content_type(basename($filename)));
$response = $response->withHeader('Content-Length', filesize($filename));
return $response;
}

private static function from(int $status, string $contentType, string $content): ResponseInterface
public static function from(int $status, string $contentType, string $content): ResponseInterface
{
$psr17Factory = new Psr17Factory();
$response = $psr17Factory->createResponse($status);
Expand Down

0 comments on commit 81a20f1

Please sign in to comment.