Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
FULL PRODUCT VERSION : ADDITIONAL OS VERSION INFORMATION : Windows XP SP2 and windows 64-bit Vista EXTRA RELEVANT SYSTEM CONFIGURATION : java 1.6 (update 1 and update 2) A DESCRIPTION OF THE PROBLEM : Files that arrive from a gzipped stream are not cached in a gzip format but getContentEncoding() still reports 'gzip' STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Write an applet that fetches a file from a server that sends it gzip encoded. Once the file is in the local cache although getContentEncoding will report 'gzip' the actual stream is not gzipped EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - Regardless of whether the connection is coming from the server or the cache I expect the stream to be gzipped (or if it's not cached in the gzip fotmat I dont' expect the getContentEncoding to tell me that it is) ACTUAL - code works unless it is getting data from the cache the getContentEncoding doesn't reflect the encoding of the cached data (I suspect it's storing the encoding details it received from the server but storing the files uncompressed) ERROR MESSAGES/STACK TRACES THAT OCCUR : Content-Encoding is gzip java.io.IOException: Not in GZIP format at java.util.zip.GZIPInputStream.readHeader(Unknown Source) at java.util.zip.GZIPInputStream.<init>(Unknown Source) at java.util.zip.GZIPInputStream.<init>(Unknown Source) ... REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- file must be grabbed from a server that will gzip the stream ... URL url=new URL(uri); connection = (HttpURLConnection)url.openConnection(); connection.setDefaultUseCaches(true); connection.setRequestProperty("Accept-Encoding","gzip"); connection.connect(); httpResponseCode=connection.getResponseCode(); System.out.println("Content-Encoding is "+connection.getContentEncoding()); if(httpResponseCode==HttpURLConnection.HTTP_OK) { String gzip="gzip"; if(gzip.equalsIgnoreCase(connection.getContentEncoding())) { // expecting a gziped stream buf=new DataInputStream(new BufferedInputStream(new GZIPInputStream(connection.getInputStream()))); } else { System.out.println("stream not gzipped, Content-Encoding is "+connection.getContentEncoding()); buf=new DataInputStream(new BufferedInputStream(connection.getInputStream())); } readBuffer(buf); .... ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : turn 'keep temporary files on my computer' off for 1.6 plugin
|