Class BufferedHttpResponse

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public final class BufferedHttpResponse
    extends HttpResponse
    HTTP response which will buffer the response's body.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      BufferedHttpResponse buffer()
      Get a new Response object wrapping this response with it's content buffered into memory.
      void close()
      Closes the response content stream, if any.
      java.io.InputStream getBody()
      Get the InputStream producing response content chunks.
      byte[] getBodyAsByteArray()
      Get the response content as a byte[].
      java.lang.String getBodyAsString()
      Get the response content as a string.
      java.lang.String getBodyAsString​(java.nio.charset.Charset charset)
      Get the response content as a string.
      HttpHeaders getHeaders()
      Get all response headers.
      java.lang.String getHeaderValue​(java.lang.String name)
      Lookup a response header with the provided name.
      int getStatusCode()
      Get the response status code.
      • Methods inherited from class java.lang.Object

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

      • BufferedHttpResponse

        public BufferedHttpResponse​(HttpResponse innerHttpResponse)
        Creates a buffered HTTP response.
        Parameters:
        innerHttpResponse - The HTTP response to buffer.
    • Method Detail

      • getStatusCode

        public int getStatusCode()
        Description copied from class: HttpResponse
        Get the response status code.
        Specified by:
        getStatusCode in class HttpResponse
        Returns:
        the response status code
      • getHeaderValue

        public java.lang.String getHeaderValue​(java.lang.String name)
        Description copied from class: HttpResponse
        Lookup a response header with the provided name.
        Specified by:
        getHeaderValue in class HttpResponse
        Parameters:
        name - the name of the header to lookup.
        Returns:
        the value of the header, or null if the header doesn't exist in the response.
      • getBody

        public java.io.InputStream getBody()
        Description copied from class: HttpResponse
        Get the InputStream producing response content chunks.
        Specified by:
        getBody in class HttpResponse
        Returns:
        The response's content as a stream.
      • getBodyAsByteArray

        public byte[] getBodyAsByteArray()
        Description copied from class: HttpResponse
        Get the response content as a byte[].
        Specified by:
        getBodyAsByteArray in class HttpResponse
        Returns:
        this response content as a byte[]
      • getBodyAsString

        public java.lang.String getBodyAsString()
        Description copied from class: HttpResponse
        Get the response content as a string.
        Specified by:
        getBodyAsString in class HttpResponse
        Returns:
        This response content as a string
      • getBodyAsString

        public java.lang.String getBodyAsString​(java.nio.charset.Charset charset)
        Description copied from class: HttpResponse
        Get the response content as a string.
        Specified by:
        getBodyAsString in class HttpResponse
        Parameters:
        charset - the charset to use as encoding
        Returns:
        This response content as a string
      • buffer

        public BufferedHttpResponse buffer()
        Description copied from class: HttpResponse
        Get a new Response object wrapping this response with it's content buffered into memory.
        Overrides:
        buffer in class HttpResponse
        Returns:
        the new Response object
      • close

        public void close()
        Description copied from class: HttpResponse
        Closes the response content stream, if any.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class HttpResponse