class HeaderFormatter implements ResponseFormatter {

    @Override
    public byte[] formatResponse(WilmaHttpRequest wilmaRequest, HttpServletResponse resp, byte[] responseResource, ParameterList params) {
        //we add/update headers based on params
        for (Parameter p : params.getAllParameters()) {
            String name = p.getName();
            String value = p.getValue();
            if (name != null && name.length() > 0 && value != null && value.length() > 0) {
                if (resp.containsHeader(name)) {
                    resp.setHeader(name, value);
                } else {
                    resp.addHeader(name, value);
                }
            } else {
                logger.warn("Template Formatter issue: specified parameters cannot be used in header: " + p.toString());
            }
        }
        //we don't touch the body part
        return responseResource;
    }

}