Class BufferingResponseListener

    • Constructor Detail

      • BufferingResponseListener

        public BufferingResponseListener()
        Creates an instance with a default maximum length of 2 MiB.
      • BufferingResponseListener

        public BufferingResponseListener​(int maxLength)
        Creates an instance with the given maximum length
        Parameters:
        maxLength - the maximum length of the content
    • Method Detail

      • onContent

        public void onContent​(Response response,
                              java.nio.ByteBuffer content)
        Description copied from interface: Response.ContentListener
        Callback method invoked when the response content has been received. This method may be invoked multiple times, and the content buffer must be consumed before returning from this method.
        Specified by:
        onContent in interface Response.ContentListener
        Overrides:
        onContent in class Response.Listener.Adapter
        Parameters:
        response - the response containing the response line data and the headers
        content - the content bytes received
      • getMediaType

        public java.lang.String getMediaType()
      • getEncoding

        public java.lang.String getEncoding()
      • getContent

        public byte[] getContent()
        Returns:
        the content as bytes
        See Also:
        getContentAsString()
      • getContentAsString

        public java.lang.String getContentAsString()
        Returns:
        the content as a string, using the "Content-Type" header to detect the encoding or defaulting to UTF-8 if the encoding could not be detected.
        See Also:
        getContentAsString(String)
      • getContentAsString

        public java.lang.String getContentAsString​(java.lang.String encoding)
        Parameters:
        encoding - the encoding of the content bytes
        Returns:
        the content as a string, with the specified encoding
        See Also:
        getContentAsString()
      • getContentAsString

        public java.lang.String getContentAsString​(java.nio.charset.Charset encoding)
        Parameters:
        encoding - the encoding of the content bytes
        Returns:
        the content as a string, with the specified encoding
        See Also:
        getContentAsString()
      • getContentAsInputStream

        public java.io.InputStream getContentAsInputStream()
        Returns:
        Content as InputStream