igniphp / framework

Swoole, PSR-15, PSR-7, PSR-11 lightweight modular anti-framework for REST micro-services.
MIT License
265 stars 14 forks source link

Add Gzip support on response #14

Closed smalot closed 6 years ago

smalot commented 6 years ago

suggest (Server.php line 188):

            // End.
            $content = $psrResponse->getBody()->getContents();

            if (!empty($request->header['accept-encoding'])) {
                $encoding = explode(',', str_replace(' ', '', $request->header['accept-encoding']));

                if (in_array('gzip', $encoding, true)) {
                    $response->gzip(1);
                } elseif (in_array('deflate', $encoding, true)) {
                    $response->header('content-encoding', 'deflate');
                    $content = gzdeflate($content);
                }
            }

            $response->end($content);

I think you'll find something better ...

dkraczkowski commented 6 years ago

PR: https://github.com/igniphp/framework/pull/17

smalot commented 6 years ago

Awesome !!! Many thanks

dkraczkowski commented 6 years ago

You are welcome :)