diff options
3 files changed, 22 insertions, 1 deletions
diff --git a/server/src/com/vaadin/server/VaadinPortletResponse.java b/server/src/com/vaadin/server/VaadinPortletResponse.java index d9f133ac8a..2b6e0c75fb 100644 --- a/server/src/com/vaadin/server/VaadinPortletResponse.java +++ b/server/src/com/vaadin/server/VaadinPortletResponse.java @@ -97,6 +97,14 @@ public class VaadinPortletResponse implements VaadinResponse { } @Override + public void setContentLength(int len) { + if (response instanceof ResourceResponse) { + ((ResourceResponse) response).setContentLength(len); + } + + } + + @Override public PrintWriter getWriter() throws IOException { if (response instanceof MimeResponse) { return ((MimeResponse) response).getWriter(); diff --git a/server/src/com/vaadin/server/VaadinResponse.java b/server/src/com/vaadin/server/VaadinResponse.java index 1d5fcf141f..c31c6c05d8 100644 --- a/server/src/com/vaadin/server/VaadinResponse.java +++ b/server/src/com/vaadin/server/VaadinResponse.java @@ -169,4 +169,17 @@ public interface VaadinResponse extends Serializable { * @see PortletResponse#addProperty(Cookie) */ public void addCookie(Cookie cookie); + + /** + * Sets the length of the content body in the response In HTTP servlets, + * this method sets the HTTP Content-Length header. For some portlet + * responses, this method sets the content-length header, for others this + * method does nothing. + * + * @param len + * an integer specifying the length of the content being returned + * to the client + * @since 7.3.8 + */ + public void setContentLength(int len); } diff --git a/server/src/com/vaadin/server/communication/UIInitHandler.java b/server/src/com/vaadin/server/communication/UIInitHandler.java index 018274330f..3a6dc1e55f 100644 --- a/server/src/com/vaadin/server/communication/UIInitHandler.java +++ b/server/src/com/vaadin/server/communication/UIInitHandler.java @@ -112,7 +112,7 @@ public abstract class UIInitHandler extends SynchronizedRequestHandler { response.setHeader("Cache-Control", "no-cache"); byte[] b = json.getBytes("UTF-8"); - response.setHeader("Content-Length", String.valueOf(b.length)); + response.setContentLength(b.length); OutputStream outputStream = response.getOutputStream(); outputStream.write(b); |