Class HttpUtils


  • public class HttpUtils
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void consumeAndClose​(java.net.HttpURLConnection connection)
      In order to be able to reuse the underlying TCP connections, the input stream must be consumed and closed see also https://docs.oracle.com/javase/8/docs/technotes/guides/net/http-keepalive.html
      static java.lang.String readToString​(java.io.InputStream inputStream)
      Reads the steam and converts the contents to a string, without closing stream.
      • Methods inherited from class java.lang.Object

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

      • readToString

        public static java.lang.String readToString​(java.io.InputStream inputStream)
                                             throws java.io.IOException
        Reads the steam and converts the contents to a string, without closing stream.
        Parameters:
        inputStream - the input stream
        Returns:
        the content of the stream as a string
        Throws:
        java.io.IOException
      • consumeAndClose

        public static void consumeAndClose​(@Nullable
                                           java.net.HttpURLConnection connection)
        In order to be able to reuse the underlying TCP connections, the input stream must be consumed and closed see also https://docs.oracle.com/javase/8/docs/technotes/guides/net/http-keepalive.html
        Parameters:
        connection - the connection