After I deployed my most recent application, I noticed GWT RPC
responses had balooned to over 100KB in size - up from 8KB. After a
few seconds of investigation, I realized this was because I was no
longer getting gzipped results back from the server. I still get 'em
from the embedded Tomcat server that ships with GWT, however - just
not via OC4J.
Where do I begin troubleshooting this? Is this going to be in GWT-
land or OAS-land? Or in Browser-land?
Thanks!
Rob
My guess would be browser-land. If you look at the code for
writeResponse in com.google.gwt.user.server.rpc.RemoteServiceServlet
you'll see this:
private void writeResponse(HttpServletRequest request,
HttpServletResponse response, String responsePayload) throws IOException {
byte[] reply = responsePayload.getBytes(CHARSET_UTF8);
String contentType = CONTENT_TYPE_TEXT_PLAIN_UTF8;
if (acceptsGzipEncoding(request)
&& shouldCompressResponse(request, response, responsePayload)) {
// Compress the reply and adjust headers.
//
ByteArrayOutputStream output = null;
GZIPOutputStream gzipOutputStream = null;
Throwable caught = null;
try {
output = new ByteArrayOutputStream(reply.length);
gzipOutputStream = new GZIPOutputStream(output);
gzipOutputStream.write(reply);
gzipOutputStream.finish();
gzipOutputStream.flush();
response.setHeader(CONTENT_ENCODING, CONTENT_ENCODING_GZIP);
reply = output.toByteArray();
} catch (UnsupportedEncodingException e) {
caught = e;
} catch (IOException e) {
caught = e;
} finally {
if (null != gzipOutputStream) {
gzipOutputStream.close();
}
if (null != output) {
output.close();
}
}
if (caught != null) {
getServletContext().log("Unable to compress response", caught);
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
}
// Send the reply.
//
response.setContentLength(reply.length);
response.setContentType(contentType);
response.setStatus(HttpServletResponse.SC_OK);
response.getOutputStream().write(reply);
}
Based on that, it looks to me like either your browser is indicating
it can't accept gzip-encoded responses or GWT is determining that the
response shouldn't be gzipped. The thing is, shouldCompressResponse
just checks the response's length against a constant to determine if
it's "long enough" to warrant compression, so I think it's your
browser.
Ian
--
Tired of pop-ups, security holes, and spyware?
Try Firefox: http://www.getfirefox.com