Class HttpURLConnectionService


  • public class HttpURLConnectionService
    extends java.lang.Object
    This bean shall be instantiated only once for the entire server/tenant.
    All methods could have been public static but are defined this way to allow overriding.
    This service only works with byte[] instead of InputStream & OutputStream. It is important that all intended input and output payloads fit into memory.
    See Also:
    HttpURLConnectionRequest, HttpURLConnectionResponse
    • Field Detail

      • connectTimeout

        protected int connectTimeout
      • readTimeout

        protected int readTimeout
    • Constructor Detail

      • HttpURLConnectionService

        public HttpURLConnectionService()
    • Method Detail

      • bufferStream

        @Nonnull
        public byte[] bufferStream​(java.io.InputStream stream)
                            throws java.io.IOException
        Utility method to extract all bytes of the InputStream and return them as a byte array.
        Parameters:
        stream - InputStream to be converted into byte[].
        Returns:
        byte array containing all bytes of the InputStream. The length of the array equals to total number of bytes read.
        Throws:
        java.io.IOException - May be thrown by the following 2 methods : InputStream.read() and InputStream.close()
      • disableHttpsCertificate

        protected void disableHttpsCertificate​(javax.net.ssl.HttpsURLConnection connection)
      • setConnectTimeout

        public void setConnectTimeout​(int connectTimeout)
        Parameters:
        connectTimeout - an int that specifies the connect timeout value in milliseconds
        See Also:
        URLConnection.setConnectTimeout(int)
      • setReadTimeout

        public void setReadTimeout​(int readTimeout)
        Parameters:
        readTimeout - an int that specifies the timeout value to be used in milliseconds
        See Also:
        URLConnection.setReadTimeout(int)
      • trace

        protected void trace​(java.util.Map<java.lang.String,​java.util.List<java.lang.String>> fields)