class SuppressFastInfosetCompression implements ResponseFormatter {

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

}