class SuppressGzipCompression implements ResponseFormatter {

    @Override
    public byte[] formatResponse(WilmaHttpRequest wilmaRequest, HttpServletResponse resp, byte[] responseResource, ParameterList params) {
        //force turn off gzip compression usage for this answer
        String acceptEncodingHeader = wilmaRequest.getHeader(HEADER_KEY_ACCEPT_ENCODING);
        if (acceptEncodingHeader != null && acceptEncodingHeader.contains(HEADER_VALUE_GZIP)) {
            String existingHeaderContent = resp.getHeader(HEADER_KEY_SUPPRESS_ENCODING);
            String newHeaderContent = existingHeaderContent == null ? HEADER_VALUE_GZIP : existingHeaderContent + "," + HEADER_VALUE_GZIP;
            resp.addHeader(HEADER_KEY_SUPPRESS_ENCODING, newHeaderContent);
        }
        //we don't touch the body part
        return responseResource;
    }

}