diff options
author | Artur Signell <artur@vaadin.com> | 2015-01-07 16:42:26 +0200 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2015-01-07 16:42:45 +0200 |
commit | 5360e23a1a6d3f8df30c1b049f857e227b665501 (patch) | |
tree | 9b69c5ce3cb69c4cfb40326e848bb9580b349540 /server | |
parent | c0b90c7e3aed4b283d6202ee6cee764631540100 (diff) | |
download | vaadin-framework-5360e23a1a6d3f8df30c1b049f857e227b665501.tar.gz vaadin-framework-5360e23a1a6d3f8df30c1b049f857e227b665501.zip |
Use API for setting content length on responses (#15504)
Change-Id: Ic8f29163442a1476406a1f2b617a4ecaf577ba93
Diffstat (limited to 'server')
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); |