Not in GZIP format problem

I am experiencing the following IOException when using the GZIPInputStream:
    java.io.IOException: Not in GZIP format
        at java.util.zip.GZIPInputStream.readHeader(GZIPInputStream.java:131)
        at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:58)
        at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:68)
        ...I am trying to read an Entity Body from an HTTP response that has been compressed using GZIP compression. I read in chunks of 4K bytes, but my first read always ends at the Entity Body (this is not a problem of course, but I thought it was a bit odd). However, this my first read of an InputStream always gives me the following:
Status-Line
Headers
CRLF
So, the next read would return me the first byte of the Entity Body. By investigating the supplied Headers I discovered that GZIP compression is used. Therefore, I create a GZIPInputStream with the original InputStream as parameter. But when I start reading from the GZIPInputStream I get the mentioned exception.
Looking into the GZIPInputStream it seems to have a problem with the GZIP header magic number (0x8b1f). This magic number consists of two bytes. I thought it would be nice to try the following, just to see what happend:
    byte[] gzipHeader = new byte[2];
    inputStream.read(gzipHeader, 0, gzipHeader.length);
    GZIPInputStream gzipInputStream =
        new GZIPInputStream(
            new SequenceInputStream(
                new ByteArrayInputStream(gzipHeader), inputStream));
    ...And guess what? This seems to solve my problem, however I would not consider this to be a nice fix. Looking to see what is in the byte array, I discovered the following: 0x1f8b. I found the following snippet of code in GZIPInputStream:
    private int readUShort(InputStream in) throws IOException {
        int b = readUByte(in);
        return ((int)readUByte(in) << 8) | b;
    }This method is used to read in the GZIP header magic number. Now correct me if I'm wrong, but reading the bytes 0x1f8b results in the desired 0x8b1f. Therefore my little test mentioned earlier works, but why doesn't the following work:
    GZipInputStream gzipInputStream = new GZIPInputStream(inputStream);
    ....Can anybody help me with this?
Jack...

http://en.wikipedia.org/wiki/Gzip
Other uses
The �Content-Encoding� header in HTTP/1.1 allows clients to optionally receive compressed HTTP responses and (less commonly) to send compressed requests. The standard itself specifies two compression methods: �gzip� (RFC 1952; the content wrapped in a gzip stream) and �deflate� (RFC 1950; the content wrapped in a zlib-formatted stream). Compressed responses are supported by many HTTP client libraries, almost all modern browsers and both of the major HTTP server platforms, Apache and Microsoft IIS. Many server implementations, however, incorrectly implement the protocol by using the raw DEFLATE stream format (RFC 1951) instead. The bug is sufficiently pervasive that most modern browsers will accept both RFC 1951 and RFC 1950-formatted data for the �deflate� compressed method.

Similar Messages

  • Oracle 9.0.1 Linux Download Disk 1 Is NOT in gzip Format

    Hi,
    I tried to download twice Oracle 9.0.1 Linux on my Windows first, then tranfer to my Linux machine. All the other disks (gz files) are transfered and uncompressed into cpio files, expect Disk 1, Linux9i_Disk1.cpio.gz.
    I checked Linux9i_Disk1.cpio.gz first using WinZip on Windows, then gunzip on Linux. The problem is the same: Linux9i_Disk1.cpio.gz is not in gzip format.
    Since all the other Disks (.cpio.gz files) works fine, my suspicion is that Linux9i_Disk1.cpio.gz is corrupted on the server. Has anyone in Oracle really tested the download recently?
    Of cause next monday I will check direct download to my Linux machine at work.
    Thanks in advance!
    Dong Liu
    So that we may better diagnose DOWNLOAD problems, please provide the following information.
    - Server name
    - Filename
    - Date/Time
    - Browser + Version
    - O/S + Version
    - Error Msg

    Hi,
    I reported that Oracle 9.0.1 Linux Download Disk 1 does not work if I first download it to Windows. My colleague downloaded it to a Linux machine, and it can be unzipped.
    So only one disk file can only be directly downloaded to Linux.

  • Not in GZIP format error while trying to unzip the file

    I'm using GZIPInputStream in order to read data from zipped file.
    It worked perfectly from command line. I have to execute the same code from crontab and it gave me the exception:
    java.io.IOException: Not in GZIP format
    It tries to check the GZIP_MAGIC number and for some reason failed.
    The stack trace I'm getting points to GZIPInputStream constructor.
    GZIPInputStream input = new GZIPInputStream( new FileInputStream( fileName));
    Any help will be highly appreciated.
    Thanks,
    Arnold

    This may be a little late for you, but I am having the same problem. I am using an encryption package as well. I created input and output streams to wrap my encryption package. (javax.?? has something similar)
    Anyway, my algorithm goes: data -> gzip -> encrypt --------- ->decrypt -> gzip ->data
    If I used encryption without the gzip everything works fine, and if I use gzip without the encryption it works fine as well. But if I use them in conjuction, bad thing happen.
    I copied versions of the GZIPInput and output stream classes from java.util.zip and made my own so I could put in debug code. Then I saw what was happening. GZIP writes a header of 8b1f. It does this by writing a first to 1f as a byte (this is 31 in decimal) and then the 8b (this is 139 unsigned byte or -117 signed byte).
    My debug code shows that it writes 31,-117 to the stream, but reads 31,139 when I don't use encryption and 31,-117 when I do. Another strange thing about this, though, is that everywhere I have debug code, this is the only byte that prints out unsigned in my debug messages... When encryption is turned on this same debug message prints -117.
    I have no idea why this is happening. To test things some more, I changed my copy of the gzipinputstream to compare this header value with the GZIP_MAGIC number (35615) and with -29921. Now everything works perfectly. There has to be a better solution for this, but I don't know what it is yet.
    GZIP_MAGIC is 8b1f sent as two bytes 1f and then 8b, and then shifting the 8b.
    -117, using the Integer.toString(-117,16), gives a hex of -75. Using the same methodology as above, we can get -751f which is -29921.
    The header check is essentially:
    if ((int)readUByte(in) << 8) | (int)readUByte(in) != GZIP_MAGIC)
    your screwed
    So change this store the value in a variable and compare it to GZIP_MAGIC and -29921 and your problem will disappear.
    I am not sure what they were thinking. readUByte is a simple read. There is nothing unsigned about it. There is probably some casting somewhere along here that is causing the error, but nothing I am doing seem incorrect.
    Hope this helps. Actually, I hope you have solved your problem by now, but if not,... If you have any insights, I would appreciate hearing them.

  • Exception invoking JSF : Not in GZIP format

    Hi,
    I am trying integrating jsf and spring.
    I am using JBoss server, JSF1.2 and Spring Framework 2.5.
    When I submit my jsf page, I am getting this exception:
    06:57:34,839 FATAL [renderkit] Not in GZIP format
    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)
         at com.sun.faces.renderkit.ResponseStateManag
    Have you experienced this problem earlier? Let me know?
    Edited by: Laddha on Nov 21, 2007 12:14 PM
    Edited by: Laddha on Nov 21, 2007 2:01 PM
    Edited by: Laddha on Nov 21, 2007 2:07 PM

    It is working now, I just hand coded the jsf page now. Probably content copied earlier was problem.

  • Applet error, "not in gzip format"

    When trying to open an applet Java console shows:
    Error in server data transaction: Not in GZIP format
    Error while downloading productGroups. Mess=Not in GZIP format
    basic: Applet initialized
    basic: Starting applet
    basic: Applet started
    basic: Told clients applet is started
    But no applet appears :-(
    Using kubuntu, firefox 3.08, java version "1.6.0_13"
    Using it in windows xp and firefox works fine.
    Any suggestions?

    When trying to open an applet Java console shows:
    Error in server data transaction: Not in GZIP format
    Error while downloading productGroups. Mess=Not in GZIP format
    basic: Applet initialized
    basic: Starting applet
    basic: Applet started
    basic: Told clients applet is started
    But no applet appears :-(
    Using kubuntu, firefox 3.08, java version "1.6.0_13"
    Using it in windows xp and firefox works fine.
    Any suggestions?

  • Not in GZip Format Exception

    Hi All,
    When decompressing zipped data using GZIPInput stream, i get this exception "Not in GZip Format Exception". I am not quite sure what to do on this. I have been through forums and all but din get any answer for this. So any help on this is highly appreciated.
    Thanks
    Jeevan

    >
    I dint get u, what is this zip != gzip?
    zip.format()) != gzip.format()

  • Getting  "IOException Not in Gzip format "

    Hi,
    I am getting this *"IOException Not in GZip format "* while Uncompresing.
    I have checked the data. It's already in gzip format (compressed).
    My Code looks like:-
    byte[] HTMLCompress = new byte[contentlength];
                byte[] HTMLUnCompress = new byte[10000];
                if(b != null) {
                    for( int total = b.length-1 , i = contentlength-1 ; i >= 0 ; i-- ){
                        HTMLCompress[i] = b[total--];
                String htmlstr = new String();
                if(HTMLCompress.length > 0) {
                    ByteArrayInputStream bs = new ByteArrayInputStream(HTMLCompress);                
                    System.out.println("Inside >> " + bs);
                    GZIPInputStream gzp = new GZIPInputStream(bs,contentlength);                
                    int noread = gzp.read(HTMLUnCompress);
                    for( int i = 0 ; i < noread ; i++ ){
                        htmlstr += (char)HTMLUnCompress;
    *Can anyone please suggest me what's the issue with this...*.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    The exception is clear : IOException Not in GZip format
    So check what contains really the variable 'b'.
    Then what does the first loop ???
    instead of
            for( int total = b.length-1 , i = contentlength-1 ; i >= 0 ; i-- ){
                HTMLCompress[i] = b[total--];
            }Try this :
            for (int i=0; i<b.length; i++) {
                HTMLCompress[i] = b;
    or System.arraycopy(b, 0, HTMLCompress, 0, contentlength);
    I repeat, probably b buffer doesn't containt gzip format. Check you stuff before sample code you posted.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • File not in GZIP format

    Hello, i have already searched the forum but no one seems to give clear answers on why GZIPInputStream gzip = new GZIPInputStream(new (*any input stream)); throws an IOException: File not in GZIP format...
    can somebody please help me with a code sample. My program sends compressed files on the network and the receiving end decompresses it. But it doesnot work because of the said exception...

    i badly need your help *: (*

  • Download 9204 DB for Linux: "not in gzip format

    as anybody else noticed problems after downloading the new 9204 drop of the Linux DB files?
    The checksums are different from what is reported on the download page, and from the content it seems there is some "garbage" at the top of the gz files?

    Ok, i found the problem.
    Although the files have the .gz extension, they are actually not gzipped. They are regular cpio archived (not compressed).

  • Not in GZip format...

    On the download page for the linux version of 9i Lite, it says to gunzip, when in fact, the file I recieved via the download was NOT gzipped at all. It was simply a renamed cpio.
    Just thought I should bring that to your attention before you get a flood of emails asking "How do I get this thing to work?" :)
    me

    hello,
    scroll down the site from where you have downloaded the file and you will know how to extract it..it is all there on the site
    Directions
                  1. Unzip the file: gunzip <filename>
                  2. Extract the file: cpio -idmv < <filename>
                  3. Installation guides and general Oracle Database 10g documentation can be found here.
                  4. Review the certification matrix for this product here.thanks and regards
    VD

  • 9ias linux download not in gzip format

    I am unable to unzip the download files ie Linux_ias1022_Disk1.cpio.gz (461,608 kb) and I have also tried to unzip them on my solaris systems with the same result. FTP binary, everything is accurate except the unzip. PLEASE ANSWER MY QUERY, SECOND POSTING.

    Now I know why you guys aren't answering my post. I downloaded another gz file from the site glibc-2.1.3-stubs.tar.gz (92 kb) and I decompressed it fine. The problem is that nothing on the ias1022 Linux download works because you don't want it to be downloaded, right? Do you really have to waste my time with this grade F technet support game? I mean I've been wasting my time with this distribution for two days, and it really is crap, right? Since the company I work for is a customer and I'm supposed to be evaluating this software, don't you think someone there should give a damn?

  • GZip Version Problems

    Hello Everyone,
    I have the need to decompress an array of bytes that are given to me in gzip format. The problem that I am facing is that I beleive that the version of gzip that the bytes are compressed with, is different than the version of gzip that is built into the java API. Every time I try to unzip the bytes using GZIPInputStream, I get the error "Not in gzip format." Is there any way I can decompress gzip files compressed with an older version of gzip? Does anyone know the version of Gzip java uses?
    Thanks for all the help
    - Jon
    Here is my decompress code:
    static byte[] Decompress(byte[] buffer) throws IOException
              ByteArrayInputStream bin = new ByteArrayInputStream(buffer);
              GZIPInputStream zip = null;
              try
                   zip = new GZIPInputStream(bin);
                   ByteArrayOutputStream bout = new ByteArrayOutputStream();
                   while(true)
                        int b = zip.read();
                        if(b == -1)
                             break;
                        bout.write(b);
                   return bout.toByteArray();
              finally
                   if (zip != null)
                        zip.close();
         }

    Jpmon1 wrote:
    It is a gzip file, we use a C++ gzip library to compress it. The version of the gzip library in C++ is 1.1. We can decompress it fine through the C++ library.Can't really diagnose the problem if you can't post standalone code. Put your gzip file into a hard-coded byte[] and post that and code that demonstrates the problem.
    EDIT: Also, are you aware there is a difference between gzip the file format, and the underlying compression mechanism (DEFLATE)?
    Edited by: paul.miner on Jan 30, 2008 10:26 AM

  • About gzip format

    I download 817solaris.cpio.gz file into my win98 pc then ftp to
    Unix box. When I try to gunzip this file. It shows it's not in
    gzip format. I even tried type bin first before ftp the whole
    file then use put command. Any suggestion?

    Hi, welcome to Apple Discussions.
    Before you start you need a complete backup of your entire iTunes Library & media plus of course any other data you'll want on your rebuilt machine.
    *Fast backup for iTunes library (Windows Only)*
    Grab SyncToy 2.1, a free tool from MS. This can be used to copy your entire iTunes library (& other important data folders) onto another hard drive or network share. You can then use SyncToy periodically to synchronise or echo your library to the backup. A preview will show which files need to be updated giving you a chance to spot unexpected changes and during the run only the new or updated files will be copied saving lots of time. And if your media is all organised below the main iTunes folder then you should also be able to open the backup library on any system running the same version of iTunes.
    When the time comes to reformat your PC, do a final sync, then open iTunes & deauthorize the PC, reformat & rebuild Windows, copy the backup folders back to the same location as they were previously, install iTunes and it should all work perfectly.
    tt2

  • Everytime I use IE, first I have to click on the IE bar to allow blocked contect to display. What is the content that is being blocked from IE? viewers may not know what the problem is and see my site totally out of format.

    Everytime I use IE, first I have to click on the IE bar to allow blocked contect to display. What is the content that is being blocked from IE? viewers may not know what the problem is and see my site totally out of format.

    discoveriweb wrote:
    This is iweb development where after publishing, things look different in IE than other browsers. U r correct that this is due to IE software but is iWeb related. After all, one uses iweb not to just publish in Safari but for all browsers.
    Which means that you are only considering half of the problem, but that's your choice.
    I'm out.

  • Yosemite 10.10 problem - 10.9 drive not mac extended format ??

    I am attempting to upgrade to 10.10 and the system is not allowing me to install on my 10.9 drive because it thinks the drive is either not mac extended formatted or journal not activated.  It will not install the update.  It requires a drive format or activate Journal.  I'm new to Apple and this does not compute!  The system says the 10.9 drive is formatted as mac os-extended (Journal).
    Thanks,

    The other thing that the installer checks on before it install OS X is that the disk drive is formatted with GUID partition mapping.

Maybe you are looking for