title: reading gzipped request in servlet
body: <p>i'm missing something in a pretty easy task: i have to check if incoming request inputstream is gzipped and ungzip its content. this without using content-type.
  i thought about something like this:</p>
  
  <p>check if request is gzipped:</p>
  
  <pre><code>private boolean isGZIPed( HttpServletRequest request )
  {
      boolean isGziped = false;
      try
      {
          PushbackInputStream pb = new PushbackInputStream( request.getInputStream(), 2 );
          byte[] signature = new byte[2];
          pb.read( signature );
          pb.unread( signature );
          int head = ( (int)signature[0] &amp; 0xff ) | ( ( signature[1] &lt;&lt; 8 ) &amp; 0xff00 );
          isGziped = GZIPInputStream.GZIP_MAGIC == head;
      }
      catch( Exception ioe )
      {
          logger.error(ioe);
      }
      return isGziped;
  }
  </code></pre>
  
  <p>ungzip it if it is gziped indeed:</p>
  
  <pre><code>if(isGziped(request) 
  {
      GZIPInputStream gzis = new GZIPInputStream( request.getInputStream() );
      InputStreamReader reader = new InputStreamReader( gzis );
      ...
  }
  </code></pre>
  
  <p>my problem is that  new GZIPInputStream( request.getInputStream() ) always throws "not a gzip format" exception. what do i miss?</p>