title: Qt quncompress gzip data
body: <p>I stumble upon a problem, and can't find a solution. </p>
  
  <p>So what I want to do is uncompress data in qt, using qUncompress(QByteArray), send from www in gzip format. I used wireshark to determine that this is valid gzip stream, also tested with zip/rar and both can uncompress it.</p>
  
  <p>Code so far, is like this:</p>
  
  <pre><code>    static const char dat[40] = {
           0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xaa, 0x2e, 0x2e, 0x49, 0x2c, 0x29,
           0x2d, 0xb6, 0x4a, 0x4b, 0xcc, 0x29, 0x4e, 0xad, 0x05, 0x00, 0x00, 0x00, 0xff, 0xff, 0x03, 0x00,
           0x2a, 0x63, 0x18, 0xc5, 0x0e, 0x00, 0x00, 0x00
      };
  //this data contains string: {status:false}, in gzip format
  QByteArray data;
             data.append( dat, sizeof(dat) );
  
  unsigned int size = 14; //expected uncompresed size, reconstruct it BigEndianes
  
  //prepand expected uncompressed size, last 4 byte in dat 0x0e = 14
  QByteArray dataPlusSize;
  
  dataPlusSize.append( (unsigned int)((size &gt;&gt; 24) &amp; 0xFF));
  dataPlusSize.append( (unsigned int)((size &gt;&gt; 16) &amp; 0xFF));
  dataPlusSize.append( (unsigned int)((size &gt;&gt; 8) &amp; 0xFF));
  dataPlusSize.append( (unsigned int)((size &gt;&gt; 0) &amp; 0xFF));
  
  QByteArray uncomp = qUncompress( dataPlusSize );
  qDebug() &lt;&lt; uncomp;
  </code></pre>
  
  <p>And uncompression fails with: qUncompress: Z_DATA_ERROR: Input data is corrupted.</p>
  
  <p>AFAIK gzip consist of 10 byte header, DEFLATE peyload, 12 byte trailer ( 8 byte CRC32 + 4 byte ISIZE - uncompresed data size ).
  Striping header and trailer should leave me with DEFLATE data stream, qUncompress yields same error. </p>
  
  <p>I checked with data string compressed in PHP, like this:</p>
  
  <pre><code>$stringData = gzcompress( "{status:false}", 1);
  </code></pre>
  
  <p>and qUncompress uncompress that data.(I didn't see and gzip header though i.e. ID1 = 0x1f, ID2 = 0x8b )
  I checked above code with debug, and error occurs at:</p>
  
  <pre><code>        if (
          #endif
              ((BITS(8) &lt;&lt; 8) + (hold &gt;&gt; 8)) % 31) { //here is error, WHY? long unsigned int hold = 35615
              strm-&gt;msg = (char *)"incorrect header check";
              state-&gt;mode = BAD;
              break;
          } 
  </code></pre>
  
  <p>inflate.c line 610.</p>
  
  <p>I know that qUncompress is simply a wrapper to zlib, so I suppose it should handle gzip without any problem. Any comments are more then welcome. </p>
  
  <p>Best regards</p>