Return-Path: X-Original-To: apmail-freemarker-notifications-archive@minotaur.apache.org Delivered-To: apmail-freemarker-notifications-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7D52118B57 for ; Sun, 25 Oct 2015 15:55:33 +0000 (UTC) Received: (qmail 25356 invoked by uid 500); 25 Oct 2015 15:55:33 -0000 Delivered-To: apmail-freemarker-notifications-archive@freemarker.apache.org Received: (qmail 25339 invoked by uid 500); 25 Oct 2015 15:55:33 -0000 Mailing-List: contact notifications-help@freemarker.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@freemarker.incubator.apache.org Delivered-To: mailing list notifications@freemarker.incubator.apache.org Received: (qmail 25330 invoked by uid 99); 25 Oct 2015 15:55:33 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 25 Oct 2015 15:55:33 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id F22A7C20EE for ; Sun, 25 Oct 2015 15:55:32 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.779 X-Spam-Level: * X-Spam-Status: No, score=1.779 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id m9CbLtppuLNc for ; Sun, 25 Oct 2015 15:55:28 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with SMTP id 1431A23032 for ; Sun, 25 Oct 2015 15:55:27 +0000 (UTC) Received: (qmail 25271 invoked by uid 99); 25 Oct 2015 15:55:27 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 25 Oct 2015 15:55:27 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id B7C402C1F5A for ; Sun, 25 Oct 2015 15:55:27 +0000 (UTC) Date: Sun, 25 Oct 2015 15:55:27 +0000 (UTC) From: "Daniel Dekany (JIRA)" To: notifications@freemarker.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Resolved] (FREEMARKER-1) Option to not to overwrite response ContentType in FreemarkerServlet MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/FREEMARKER-1?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniel Dekany resolved FREEMARKER-1. ------------------------------------ Resolution: Fixed Fix Version/s: 2.3.24 > Option to not to overwrite response ContentType in FreemarkerServlet > -------------------------------------------------------------------- > > Key: FREEMARKER-1 > URL: https://issues.apache.org/jira/browse/FREEMARKER-1 > Project: Apache Freemarker > Issue Type: Improvement > Reporter: Woonsan Ko > Assignee: Daniel Dekany > Priority: Minor > Fix For: 2.3.24 > > > FreemarkerServlet doesn't have to set response ContentType by default. Especially when a controller in an MVC framework sets the response ContentType, it's better to not set the response ContentType again by the default ContentType setting in FreemarkerServlet according to servlet specification (SRV.5.2 and SRV.14.2.22.1): > {quote} > Servlet programmers are responsible for ensuring that the Content-Type header is appropriately set in the response object for the content the servlet is generating. The HTTP 1.1 specification does not require that this header be set in an HTTP response. Servlet containers must not set a default content type when the servlet programmer does not set the type. > {quote} > {quote} > ServletResponse#getContentType() should "Returns the content type used for the MIME body sent in this response. The content type proper must have been specified using setContentType(String) before the response is committed. If no content type has been specified, this method returns null. If a content type has been specified and a character encoding has been explicitly or implicitly specified as described in getCharacterEncoding() , the charset parameter is included in the string returned. If no character encoding has been specified, the charset parameter is omitted. > Returns: a String specifying the content type, for example, text/html; charset=UTF-8, or null > Since: 2.4 > {quote} > So, optionally, if #getContentType() returns null, then FreemarkerServlet can detect that the Content-Type was never set before. > Actually, frameworks or containers don't have to set Content-Type if programmers don't. However, I think setting Content-Type header in the framework level (freemarker servlet in this case) to a reasonable default value seems fine. > Daniels's remarks/suggestions on this in the old ML: > {quote} > The contentType matter... thanks for looking after these! So then, FreemarkerServlet surely should set the HttpServletResponse contentType when it's still null. OTOH there should be an option to only set it then (if it's not null), not always as it happens now. So then the "ContetType" init-param remains as is, and we add a new init-param, "OverrideResponseContentType" (better name?), whose default is true for backward compatibility, but this default can be changed to false by extending FreemarkerServlet. WDYT? > {quote} -- This message was sent by Atlassian JIRA (v6.3.4#6332)