class GzipCompressorProcessor implements ResponseProcessor {

    @Override
    public byte[] process(final HttpServletRequest req, final HttpServletResponse resp, final byte[] responseBody) {
        byte[] result = responseBody;
        if (isGzipCompressionNeeded(req, resp)) {
            resp.addHeader(HEADER_KEY_CONTENT_ENCODING, HEADER_VALUE_GZIP);
            result = compressResponseStreamWithGzip(inputStreamFactory.createByteArrayInputStream(responseBody));
        }
        return result;
    }

}