Class AbstractResponseListener
java.lang.Object
org.eclipse.jetty.client.AbstractResponseListener
- All Implemented Interfaces:
EventListener
,Response.AsyncContentListener
,Response.BeginListener
,Response.CompleteListener
,Response.ContentListener
,Response.ContentSourceListener
,Response.FailureListener
,Response.HeaderListener
,Response.HeadersListener
,Response.Listener
,Response.ResponseListener
,Response.SuccessListener
- Direct Known Subclasses:
BufferingResponseListener
,RetainingResponseListener
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractResponseListener
(RetainableByteBuffer.Mutable accumulator) -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
getContentAsString
(String encoding) getContentAsString
(Charset charset) long
void
onContent
(Response response, Content.Chunk chunk, Runnable demander) Callback method invoked when the response content has been received, parsed and there is demand.void
Callback method invoked when the response has failed in the process of being receivedvoid
Callback method invoked when all the response headers have been received and parsed.void
Callback method invoked when the whole response has been successfully received.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.jetty.client.Response.AsyncContentListener
onContentSource
Methods inherited from interface org.eclipse.jetty.client.Response.Listener
onBegin, onComplete, onContent, onHeader
-
Constructor Details
-
AbstractResponseListener
-
-
Method Details
-
getMaxLength
public long getMaxLength() -
getEncoding
-
getMediaType
-
onHeaders
Description copied from interface:Response.HeadersListener
Callback method invoked when all the response headers have been received and parsed.- Specified by:
onHeaders
in interfaceResponse.HeadersListener
- Specified by:
onHeaders
in interfaceResponse.Listener
- Parameters:
response
- the response containing the response line data and the headers
-
onContent
Description copied from interface:Response.AsyncContentListener
Callback method invoked when the response content has been received, parsed and there is demand. Thechunk
must be consumed, copied, or retained before returning from this method as it is then automatically released. Thedemander
must be run before this method may be invoked again.- Specified by:
onContent
in interfaceResponse.AsyncContentListener
- Specified by:
onContent
in interfaceResponse.ContentListener
- Parameters:
response
- the response containing the response line data and the headerschunk
- the chunk receiveddemander
- 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
Description copied from interface:Response.SuccessListener
Callback method invoked when the whole response has been successfully received.- Specified by:
onSuccess
in interfaceResponse.Listener
- Specified by:
onSuccess
in interfaceResponse.SuccessListener
- Parameters:
response
- the response containing the response line data and the headers
-
onFailure
Description copied from interface:Response.FailureListener
Callback method invoked when the response has failed in the process of being received- Specified by:
onFailure
in interfaceResponse.FailureListener
- Specified by:
onFailure
in interfaceResponse.Listener
- Parameters:
response
- the response containing data up to the point the failure happenedfailure
- the failure happened
-
getContent
public byte[] getContent()- Returns:
- the content as a byte array.
- See Also:
-
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
-
getContentAsString
-
getContentAsInputStream
- Returns:
- the content as
InputStream
-