| java.lang.Object org.wings.io.GZIPCompressingDevice
GZIPCompressingDevice | final public class GZIPCompressingDevice implements Device(Code) | | A Device encapsulating an OutputStream, compressing its
output. You can use this, if the browser states, that it can handle
compressed data; don't forget to set the appropriate header, then
(Content-Encoding).
Override
DeviceFactory and declare the updated factory in web.xml to use other devices.
Example Draft
String mimeType = extInfo.getMimeType();
// some browsers can handle a gziped stream only for text-files.
if (mimeType != null && mimeType.startsWith("text/")) {
String acceptEncoding = req.getHeader("Accept-Encoding");
int gzipPos;
if (acceptEncoding != null
&& (gzipPos = acceptEncoding.indexOf("gzip")) >= 0) {
// some browsers send 'x-gzip', others just 'gzip'. Our
// response should be the same.
boolean isXGZip = (gzipPos >= 2
&& acceptEncoding.charAt(gzipPos-1) == '-'
&& acceptEncoding.charAt(gzipPos-2) == 'x');
response.addHeader("Content-Encoding",
(isXGZip ? "x-gzip" : "gzip"));
return new GZIPCompressingDevice(response.getOutputStream());
}
}
return new ServletDevice(response.getOutputStream());
}
author: Henner Zeller |
isSizePreserving | public boolean isSizePreserving()(Code) | | this returns false, since the compressing device is not size
preserving. Thats what is all about, right ?
|
|
|