Skip to content

Commit

Permalink
Return value of $next($request) can be value - prepared code to be pr…
Browse files Browse the repository at this point in the history
…operly used now
  • Loading branch information
christoph-kluge committed Mar 3, 2019
1 parent d151b8b commit a2d08b7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/ResponseCompressionMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct(array $compressors = [])
}
}

public function __invoke(ServerRequestInterface $request, $next)
public function __invoke(ServerRequestInterface $request, callable $next)
{
if (!$request->hasHeader('Accept-Encoding')) {
return $next($request);
Expand All @@ -35,7 +35,8 @@ public function __invoke(ServerRequestInterface $request, $next)
return $next($request);
}

return $next($request)->then(function (Response $response) use ($compressor) {
$response = \React\Promise\resolve($next($request));
return $response->then(function (Response $response) use ($compressor) {
// response got already encoded
if ($response->hasHeader('Content-Encoding')) {
return $response;
Expand Down

0 comments on commit a2d08b7

Please sign in to comment.