Class GZConnectionRequest

java.lang.Object
com.codename1.io.ConnectionRequest
com.codename1.io.gzip.GZConnectionRequest
All Implemented Interfaces:
IOProgressListener

public class GZConnectionRequest extends ConnectionRequest

A connection request that can detect a GZipped response, parse it automatically and unzip it. Notice that some devices (iOS) always request gzip'ed data and always decompress it for us, however in the case of iOS it doesn't remove the gziped header. The GZConnectionRequest is aware of such behaviors so it's better to use that when connecting to the network (if applicable).

By default GZConnectionRequest doesn't request gzipped data (only unzips it when its received) but it's pretty easy to do so just add the HTTP header Accept-Encoding: gzip e.g.:

GZConnectionRequest con = new GZConnectionRequest();
con.addRequestHeader("Accept-Encoding", "gzip");
  • Constructor Details

    • GZConnectionRequest

      public GZConnectionRequest()
  • Method Details

    • equals

      public boolean equals(java.lang.Object o)
      Description copied from class: ConnectionRequest
      Overrides:
      equals in class ConnectionRequest
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class ConnectionRequest
    • readHeaders

      protected void readHeaders(java.lang.Object connection) throws java.io.IOException

      Allows reading the headers from the connection by calling the getHeader() method.

      Parameters
      • connection: used when invoking getHeader
      Throws
      • java.io.IOException: thrown on failure
      Overrides:
      readHeaders in class ConnectionRequest
      Throws:
      java.io.IOException
    • readResponse

      protected final void readResponse(java.io.InputStream input) throws java.io.IOException
      Overridden to convert the input stream you should now override readUnzipedResponse()
      Overrides:
      readResponse in class ConnectionRequest
      Throws:
      java.io.IOException
    • readUnzipedResponse

      protected void readUnzipedResponse(java.io.InputStream input) throws java.io.IOException

      This method can be overridden instead of readResponse

      Parameters
      • input: an input stream that is guaranteed to be deflated
      Throws:
      java.io.IOException