Class HttpResponse

    • Constructor Detail

      • HttpResponse

        public HttpResponse​(java.net.URL url,
                            int statusCode,
                            byte[] content,
                            java.util.Map<java.lang.String,​java.util.List<java.lang.String>> headers)
      • HttpResponse

        public HttpResponse​(java.net.URL url,
                            int statusCode,
                            java.io.InputStream inputStream,
                            java.util.Map<java.lang.String,​java.util.List<java.lang.String>> headers)
      • HttpResponse

        public HttpResponse​(java.net.URL url,
                            int statusCode,
                            HttpContent content,
                            java.util.Map<java.lang.String,​java.util.List<java.lang.String>> headers)
    • Method Detail

      • getURL

        public java.net.URL getURL()
        Returns:
        The request url
      • getStatusCode

        public int getStatusCode()
        Returns:
        The status code of the response
      • getStatusMessage

        public java.lang.String getStatusMessage()
        Returns:
        The message of the status code
      • getContent

        public HttpContent getContent()
        Returns:
        The content of the response
      • getDecodedContent

        public HttpContent getDecodedContent()
        Get the decoded content of the response.
        Supported encodings are:
        • identify (no encoding)
        • gzip (also x-gzip)
        • deflate
        Library support for the following encodings is also included, if the respective library is available on the classpath:
        • brotli
          • com.aayushatharva.brotli4j:brotli4j
          • org.brotli:dec
        • zstd
          • io.airlift:aircompressor
          • io.airlift:aircompressor-v3
          • com.github.luben:zstd-jni
        Returns:
        The decoded content
        See Also:
        getDecodedContent(DecoderProvider)
      • getDecodedContent

        public HttpContent getDecodedContent​(HttpResponse.DecoderProvider decoderProvider)
        Get the decoded content of the response.
        Closing the returned content will also close the original content.
        If the content is not encoded, or uses an unsupported encoding, the original content will be returned.
        The HttpHeaders.CONTENT_ENCODING header is renamed to Original-Content-Encoding if the content has been decoded.
        Parameters:
        decoderProvider - The provider for content decoders
        Returns:
        The decoded content