Class JavaResponse

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.net.http.HttpResponse<java.io.InputStream> response  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static byte[] getBytes​(java.io.InputStream is)  
      private java.lang.String getCharset​(java.lang.String charset)  
      java.io.InputStream getContent()
      Returns the body content of the response as a InputStream.
      byte[] getContentAsBytes()
      Returns the body as bytes.
      java.lang.String getContentAsString()
      Returns the body as UTF-8 String.
      java.lang.String getContentAsString​(java.lang.String charset)
      Returns the body as UTF-8 String.
      java.io.InputStreamReader getContentReader()
      Returns the body content of the response as a InputStreamReader.
      java.lang.String getContentType()
      Returns the mime type of the response content as indicated by the Content-Type header or a empty string if none is supplied (e.g.
      java.lang.String getEncoding()
      Returns the encoding of the response as indicated by the Content-Encoding header or returns a empty string if none provided.
      Headers getHeaders()
      Returns the received response headers.
      int getStatus()
      Returns the status code for this response.
      java.lang.String getStatusText()
      Returns the status text for this response.
      boolean hasContent()
      Indicates that the response has content
      private static boolean isGzipped​(java.lang.String value)  
      • Methods inherited from class java.lang.Object

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

      • response

        private final java.net.http.HttpResponse<java.io.InputStream> response
    • Constructor Detail

      • JavaResponse

        public JavaResponse​(java.net.http.HttpResponse<java.io.InputStream> response,
                            Config config,
                            HttpRequestSummary summary)
    • Method Detail

      • getStatus

        public int getStatus()
        Description copied from interface: RawResponse
        Returns the status code for this response.
        Returns:
        the response code
      • getStatusText

        public java.lang.String getStatusText()
        Description copied from interface: RawResponse
        Returns the status text for this response.
        Returns:
        the response text
      • getHeaders

        public Headers getHeaders()
        Description copied from interface: RawResponse
        Returns the received response headers.
        Returns:
        the response headers
      • getContent

        public java.io.InputStream getContent()
        Description copied from interface: RawResponse
        Returns the body content of the response as a InputStream. Like most InputStreams it can only be read once. If you read the response though some other method like getContentAsBytes() or getBodyAsString() it will read this method and consume the InputStream
        Returns:
        the content
      • getContentAsBytes

        public byte[] getContentAsBytes()
        Description copied from interface: RawResponse
        Returns the body as bytes. This consumes the entire InputStream. Warning: Calling this on very large responses will place all data in memory and could create OutOfMemory errors
        Returns:
        the content as bytes
      • getBytes

        private static byte[] getBytes​(java.io.InputStream is)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • isGzipped

        private static boolean isGzipped​(java.lang.String value)
      • getContentAsString

        public java.lang.String getContentAsString()
        Description copied from interface: RawResponse
        Returns the body as UTF-8 String. This consumes the entire InputStream. Warning: Calling this on very large responses will place all data in memory and could create OutOfMemory errors Using this method with a binary response will make you sad
        Returns:
        the content as a UTF-8 String
      • getContentAsString

        public java.lang.String getContentAsString​(java.lang.String charset)
        Description copied from interface: RawResponse
        Returns the body as UTF-8 String. This consumes the entire InputStream. Warning: Calling this on very large responses will place all data in memory and could create OutOfMemory errors Using this method with a binary response will make you sad
        Parameters:
        charset - the charset for the String
        Returns:
        the content as a string in the provided charset.
      • getCharset

        private java.lang.String getCharset​(java.lang.String charset)
      • getContentReader

        public java.io.InputStreamReader getContentReader()
        Description copied from interface: RawResponse
        Returns the body content of the response as a InputStreamReader. Like most InputStreams it can only be read once. If you read the response though some other method like getContentAsBytes() or getBodyAsString() it will read this method and consume the InputStream
        Returns:
        the content
      • hasContent

        public boolean hasContent()
        Description copied from interface: RawResponse
        Indicates that the response has content
        Returns:
        boolean indicating that the response has content.
      • getContentType

        public java.lang.String getContentType()
        Description copied from interface: RawResponse
        Returns the mime type of the response content as indicated by the Content-Type header or a empty string if none is supplied (e.g. application/json)
        Returns:
        the Content-Type
      • getEncoding

        public java.lang.String getEncoding()
        Description copied from interface: RawResponse
        Returns the encoding of the response as indicated by the Content-Encoding header or returns a empty string if none provided.
        Returns:
        the encoding