Reviewers: tms,
Description:
Call GZIPOutputStream.finish() from RpcServlet.processPost() to ensure
the data received by the browser is properly formatted.
Patch by: bobv
Review by: tms
Please review this at http://gwt-code-reviews.appspot.com/722801/show
Affected files:
M user/src/com/google/gwt/rpc/server/RpcServlet.java
Index: user/src/com/google/gwt/rpc/server/RpcServlet.java
===================================================================
--- user/src/com/google/gwt/rpc/server/RpcServlet.java (revision 8420)
+++ user/src/com/google/gwt/rpc/server/RpcServlet.java (working copy)
@@ -203,12 +203,14 @@
response.setCharacterEncoding("UTF-8");
// Configure the OutputStream based on configuration and capabilities
+ boolean canCompress = RPCServletUtils.acceptsGzipEncoding(request)
+ && shouldCompressResponse(request, response);
+
OutputStream out;
if (DUMP_PAYLOAD) {
out = new ByteArrayOutputStream();
- } else if (RPCServletUtils.acceptsGzipEncoding(request)
- && shouldCompressResponse(request, response)) {
+ } else if (canCompress) {
RPCServletUtils.setGzipEncodingHeader(response);
out = new GZIPOutputStream(response.getOutputStream());
@@ -223,6 +225,13 @@
byte[] bytes = ((ByteArrayOutputStream) out).toByteArray();
System.out.println(new String(bytes, "UTF-8"));
response.getOutputStream().write(bytes);
+ } else if (canCompress) {
+ /*
+ * We want to write the end of the gzip data, but not close the
underlying
+ * OutputStream in case there are servlet filters that want to write
+ * headers after processPost().
+ */
+ ((GZIPOutputStream) out).finish();
}
}
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors