]> source.dussan.org Git - vaadin-framework.git/commitdiff
Use API for setting content length on responses (#15504)
authorArtur Signell <artur@vaadin.com>
Wed, 7 Jan 2015 14:42:26 +0000 (16:42 +0200)
committerArtur Signell <artur@vaadin.com>
Wed, 7 Jan 2015 14:42:45 +0000 (16:42 +0200)
Change-Id: Ic8f29163442a1476406a1f2b617a4ecaf577ba93

server/src/com/vaadin/server/VaadinPortletResponse.java
server/src/com/vaadin/server/VaadinResponse.java
server/src/com/vaadin/server/communication/UIInitHandler.java

index d9f133ac8aba4ea81ee7605a1a183f99d1f290d7..2b6e0c75fbb4383abf7cf1741a3ce58720dd0593 100644 (file)
@@ -96,6 +96,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) {
index 1d5fcf141f465a7f5e0d990c37c91baf840a858e..c31c6c05d82fbc31569a518839772a68e1323712 100644 (file)
@@ -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);
 }
index 018274330fe4abfeb742995042aed4861adf23da..3a6dc1e55fcf6edd88a2c5acf1b31955292eb2b6 100644 (file)
@@ -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);