protected function isCompressable(ServerRequestInterface $request, ResponseInterface $response): bool
    {
        if ($request->getMethod() === Http::HEAD) {
            return false;
        }

        if (Http::isResponseWithoutBody($response->getStatusCode())) {
            return false;
        }

        if (!$response->hasHeader('Content-Type')) {
            return false;
        }

        $encoding = \strtolower(\preg_replace("';.*$'", '', $response->getHeaderLine('Content-Encoding')));

        switch ($encoding) {
            case '':
            case 'identity':
                // These can be compressed.
                break;
            default:
                return false;
        }

        try {
            $media = new MediaType(\preg_replace("';.*$'", '', $response->getHeaderLine('Content-Type')));
        } catch (InvalidMediaTypeException $e) {
            return false;
        }

        if (isset($this->types[(string) $media])) {
            return true;
        }

        foreach ($media->getSubTypes() as $sub) {
            if (isset($this->subTypes[$sub])) {
                return true;
            }
        }

        return false;
    }
protected function isCompressable(ServerRequestInterface $request, ResponseInterface $response): bool
    {
        if ($request->getMethod() === Http::HEAD) {
            return false;
        }

        if (Http::isResponseWithoutBody($response->getStatusCode())) {
            return false;
        }

        if (!$response->hasHeader('Content-Type')) {
            return false;
        }

        $encoding = \strtolower(\preg_replace("';.*$'", '', $response->getHeaderLine('Content-Encoding')));

        switch ($encoding) {
            case '':
            case 'identity':
                // These can be compressed.
                break;
            default:
                return false;
        }

        try {
            $media = new MediaType(\preg_replace("';.*$'", '', $response->getHeaderLine('Content-Type')));
        } catch (InvalidMediaTypeException $e) {
            return false;
        }

        if (isset($this->types[(string) $media])) {
            return true;
        }

        foreach ($media->getSubTypes() as $sub) {
            if (isset($this->subTypes[$sub])) {
                return true;
            }
        }

        return false;
    }
protected function isCompressable ( ServerRequestInterface $ request , ResponseInterface $ response ) : bool { if ( $ request -> getMethod ( ) === Http :: HEAD ) { return false ; } if ( Http :: isResponseWithoutBody ( $ response -> getStatusCode ( ) ) ) { return false ; } if ( ! $ response -> hasHeader ( 'Content-Type' ) ) { return false ; } $ encoding = \ strtolower ( \ preg_replace ( "';.*$'" , '' , $ response -> getHeaderLine ( 'Content-Encoding' ) ) ) ; switch ( $ encoding ) { case '' : case 'identity' : // These can be compressed. break ; default : return false ; } try { $ media = new MediaType ( \ preg_replace ( "';.*$'" , '' , $ response -> getHeaderLine ( 'Content-Type' ) ) ) ; } catch ( InvalidMediaTypeException $ e ) { return false ; } if ( isset ( $ this -> types [ ( string ) $ media ] ) ) { return true ; } foreach ( $ media -> getSubTypes ( ) as $ sub ) { if ( isset ( $ this -> subTypes [ $ sub ] ) ) { return true ; } } return false ; }
Check if the given response payload should be compressed.
Check if the given response payload should be compressed .