| @@ 20-28 (lines=9) @@ | ||
| 17 | * |
|
| 18 | * @return ResponseInterface |
|
| 19 | */ |
|
| 20 | public function gzip(ResponseInterface $response) |
|
| 21 | { |
|
| 22 | $stream = Middleware::createStream(); |
|
| 23 | $stream->write(gzencode((string) $response->getBody())); |
|
| 24 | ||
| 25 | return $response |
|
| 26 | ->withHeader('Content-Encoding', 'gzip') |
|
| 27 | ->withBody($stream); |
|
| 28 | } |
|
| 29 | ||
| 30 | /** |
|
| 31 | * Gzip minifier using gzdeflate(). |
|
| @@ 37-45 (lines=9) @@ | ||
| 34 | * |
|
| 35 | * @return ResponseInterface |
|
| 36 | */ |
|
| 37 | public function deflate(ResponseInterface $response) |
|
| 38 | { |
|
| 39 | $stream = Middleware::createStream(); |
|
| 40 | $stream->write(gzdeflate((string) $response->getBody())); |
|
| 41 | ||
| 42 | return $response |
|
| 43 | ->withHeader('Content-Encoding', 'deflate') |
|
| 44 | ->withBody($stream); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||