Class ConnectionSupport


  • public final class ConnectionSupport
    extends java.lang.Object
    Provides some static helper methods that make it easier to enable features of HTTP connections such as server-side compression.
    Since:
    3.0
    Author:
    Chris Jennings
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void enableCompression​(java.net.URLConnection c)
      Sets request properties on the connection that allow the server to send compressed data.
      static java.io.InputStream openStream​(java.net.URLConnection c, int bufferSizeHint)
      Returns a buffered input stream for the connection.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • enableCompression

        public static void enableCompression​(java.net.URLConnection c)
        Sets request properties on the connection that allow the server to send compressed data.
        Parameters:
        c - the connection to modify
      • openStream

        public static java.io.InputStream openStream​(java.net.URLConnection c,
                                                     int bufferSizeHint)
                                              throws java.io.IOException
        Returns a buffered input stream for the connection. Connects to the server and obtains an input stream. If the server is sending compressed data, the input stream will be wrapped in an appropriate decompressing filter stream so that any compression is transparent to the client.

        Although the returned stream is guaranteed to be buffered, it is not guaranteed to be assignable to BufferedInputStream.

        Parameters:
        c - the connection to obtain an input stream for
        bufferSizeHint - the suggested buffer size, or -1 to use default values
        Returns:
        a buffered input stream for the content that will transparently decompress the stream if compressed
        Throws:
        java.io.IOException - if an I/O error occurs while connecting to the server