Class AbstractResponseListener

java.lang.Object
org.eclipse.jetty.client.AbstractResponseListener
  • Constructor Details

  • Method Details

    • getMaxLength

      public long getMaxLength()
    • getEncoding

      public String getEncoding()
    • getMediaType

      public String getMediaType()
    • onHeaders

      public void onHeaders(Response response)
      Description copied from interface: Response.HeadersListener
      Callback method invoked when all the response headers have been received and parsed.
      Specified by:
      onHeaders in interface Response.HeadersListener
      Specified by:
      onHeaders in interface Response.Listener
      Parameters:
      response - the response containing the response line data and the headers
    • onContent

      public void onContent(Response response, Content.Chunk chunk, Runnable demander) throws Exception
      Description copied from interface: Response.AsyncContentListener
      Callback method invoked when the response content has been received, parsed and there is demand. The chunk must be consumed, copied, or retained before returning from this method as it is then automatically released. The demander must be run before this method may be invoked again.
      Specified by:
      onContent in interface Response.AsyncContentListener
      Specified by:
      onContent in interface Response.ContentListener
      Parameters:
      response - the response containing the response line data and the headers
      chunk - the chunk received
      demander - the runnable to be run to demand the next chunk
      Throws:
      Exception - an uncaught exception will abort the response, release the chunk and fail the content source from which the chunk was read from
    • onSuccess

      public void onSuccess(Response response)
      Description copied from interface: Response.SuccessListener
      Callback method invoked when the whole response has been successfully received.
      Specified by:
      onSuccess in interface Response.Listener
      Specified by:
      onSuccess in interface Response.SuccessListener
      Parameters:
      response - the response containing the response line data and the headers
    • onFailure

      public void onFailure(Response response, Throwable failure)
      Description copied from interface: Response.FailureListener
      Callback method invoked when the response has failed in the process of being received
      Specified by:
      onFailure in interface Response.FailureListener
      Specified by:
      onFailure in interface Response.Listener
      Parameters:
      response - the response containing data up to the point the failure happened
      failure - the failure happened
    • getContent

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

      public 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

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

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

      public InputStream getContentAsInputStream()
      Returns:
      the content as InputStream