Author: thomas.heute(a)jboss.com
Date: 2009-09-16 11:59:35 -0400 (Wed, 16 Sep 2009)
New Revision: 13804
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java
Log:
Ignore attempts to change the content type once the output stream is obtained
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java 2009-09-10
19:24:02 UTC (rev 13803)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java 2009-09-16
15:59:35 UTC (rev 13804)
@@ -61,7 +61,13 @@
/** . */
private ContentBuffer responseContent;
+ /**
+ * The setContentType method must be called before the getWriter
+ * getPortletOutputStream methods. If called after, it should be ignored.
+ */
+ private boolean canSetContentType;
+
public MimeResponseImpl(PortletInvocation invocation, PortletRequestImpl preq)
{
super(invocation, preq);
@@ -73,6 +79,7 @@
this.bufferSize = 0;
this.contentTypeSet = false;
this.responseContent = new ContentBuffer();
+ this.canSetContentType = true;
}
protected abstract ContentResponse createMarkupResponse(
@@ -125,12 +132,17 @@
public void setContentType(String contentType)
{
- responseContent.setContentType(contentType);
- contentTypeSet = true;
+ if (canSetContentType)
+ {
+ responseContent.setContentType(contentType);
+ contentTypeSet = true;
+ }
+
}
public PrintWriter getWriter() throws IOException
{
+ canSetContentType = false;
if (responseContent.getContentType() == null)
{
responseContent.setContentType(preq.getResponseContentType());
@@ -142,6 +154,7 @@
public OutputStream getPortletOutputStream() throws IOException
{
+ canSetContentType = false;
if (responseContent.getContentType() == null)
{
responseContent.setContentType(preq.getResponseContentType());