summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2015-01-07 16:42:26 +0200
committerArtur Signell <artur@vaadin.com>2015-01-07 17:28:16 +0200
commit848c92d3626134a876846195edcc2ab219c0378e (patch)
tree13b41daf56f39d81c1c69fcffce61606d33f96b9 /server
parentd73d31bb4260ad621075a894d2418878b29e0388 (diff)
downloadvaadin-framework-848c92d3626134a876846195edcc2ab219c0378e.tar.gz
vaadin-framework-848c92d3626134a876846195edcc2ab219c0378e.zip
Use API for setting content length on responses (#15504)7.3.8
Change-Id: Ic8f29163442a1476406a1f2b617a4ecaf577ba93
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/server/VaadinPortletResponse.java8
-rw-r--r--server/src/com/vaadin/server/VaadinResponse.java13
-rw-r--r--server/src/com/vaadin/server/communication/UIInitHandler.java2
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 d0b9aaaf15..fd8e8c005e 100644
--- a/server/src/com/vaadin/server/communication/UIInitHandler.java
+++ b/server/src/com/vaadin/server/communication/UIInitHandler.java
@@ -115,7 +115,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);