public static void ensureContentTypeHeader(FacesContext facesContext, String contentType) {
// TODO PortletRequest
if (facesContext.getExternalContext().getResponse() instanceof HttpServletResponse) {
HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
if (!response.containsHeader("Content-Type")) {
response.setContentType(contentType);
} else {
try {
String responseContentType = response.getContentType();
if (!responseContentType.equalsIgnoreCase(contentType)) {