Methods Summary |
---|
public static java.io.InputStream | handleGZIP(java.io.InputStream is)This method checks if the input stream is a GZIP stream.
It reads the first two bytes of the stream and compares
the short it reads with the GZIP magic number
(see java.util.zip.GZIPInputStream.GZIP_MAGIC).
If the magic number matches, the method returns a
java.util.zip.GZIPInputStream which wraps the
input stream. Otherwise, the method returns either the
unchanged stream or a BufferedInputStream
if the input stream did not support marking, as defined
by the java.io.InputStream.mark method.
// Wrap the stream if it does not support marking.
// BufferedInputStream supports marking.
//Temporary: wrap all input streams to workaround bug in WTK (CR 6335742)
//Temporary: //if (!is.markSupported())
is = new BufferedInputStream(is);
int magicIn = 0;
try {
is.mark(2);
magicIn = 0x0000ffff & (is.read() | is.read() << 8);
} catch (IOException ex) {
// We were not able to read at least two bytes,
// this cannot be a GZIP stream as it does not
// even have the magic number header
is.reset();
return is;
} finally {
try {
is.reset();
} catch (IOException ioe) {
// This should _never_ happen because we do not fall
// into _any_ of the conditions that might cause a
// reset() to throw an IOException. If we got into that
// situation, it means we are in serious troubles.
throw new Error();
}
}
if (magicIn == GZIPInputStream.GZIP_MAGIC) {
return new GZIPInputStream(is);
}
return is;
|
public static java.io.InputStream | openHandleGZIP(java.lang.String svgURI)If GZIP encoding is supported, this method should setup the
HTTP Request Header to declare that GZIP encoding is supported.
InputConnection svgURLConnection =
(InputConnection)Connector.open(svgURI, Connector.READ);
try {
if (svgURLConnection instanceof HttpConnection) {
setupHttpEncoding((HttpConnection)svgURLConnection);
}
return(svgURLConnection.openInputStream());
} finally {
svgURLConnection.close();
}
|
static void | setupHttpEncoding(javax.microedition.io.HttpConnection httpC)
String encodings =
httpC.getRequestProperty(HTTP_ACCEPT_ENCODING);
if (encodings == null) {
encodings = "";
}
if (encodings.trim().length() > 0) {
encodings += ",";
}
encodings += HTTP_GZIP_ENCODING;
httpC.setRequestProperty(HTTP_ACCEPT_ENCODING, encodings);
|