Class BufferingResponseListener
- java.lang.Object
-
- org.eclipse.jetty.client.api.Response.Listener.Adapter
-
- org.eclipse.jetty.client.util.BufferingResponseListener
-
- All Implemented Interfaces:
java.util.EventListener
,Response.AsyncContentListener
,Response.BeginListener
,Response.CompleteListener
,Response.ContentListener
,Response.DemandedContentListener
,Response.FailureListener
,Response.HeaderListener
,Response.HeadersListener
,Response.Listener
,Response.ResponseListener
,Response.SuccessListener
- Direct Known Subclasses:
FutureResponseListener
@Deprecated(since="2021-05-27") public abstract class BufferingResponseListener extends Response.Listener.Adapter
Deprecated.The Eclipse Jetty and Apache Felix Http Jetty packages are no longer supported.Implementation of
Response.Listener
that buffers the content up to a maximum length specified to the constructors.The content may be retrieved from
Response.Listener.onSuccess(Response)
oronComplete(Result)
viagetContent()
orgetContentAsString()
.Instances of this class are not reusable, so one must be allocated for each request.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.client.api.Response.Listener
Response.Listener.Adapter
-
-
Constructor Summary
Constructors Constructor Description BufferingResponseListener()
Deprecated.Creates an instance with a default maximum length of 2 MiB.BufferingResponseListener(int maxLength)
Deprecated.Creates an instance with the given maximum length
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description byte[]
getContent()
Deprecated.java.io.InputStream
getContentAsInputStream()
Deprecated.java.lang.String
getContentAsString()
Deprecated.java.lang.String
getContentAsString(java.lang.String encoding)
Deprecated.java.lang.String
getContentAsString(java.nio.charset.Charset encoding)
Deprecated.java.lang.String
getEncoding()
Deprecated.java.lang.String
getMediaType()
Deprecated.abstract void
onComplete(Result result)
Deprecated.Callback method invoked when the request and the response have been processed, either successfully or not.void
onContent(Response response, java.nio.ByteBuffer content)
Deprecated.Callback method invoked when the response content has been received, parsed and there is demand.void
onHeaders(Response response)
Deprecated.Callback method invoked when all the response headers have been received and parsed.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.jetty.client.api.Response.AsyncContentListener
onContent
-
Methods inherited from interface org.eclipse.jetty.client.api.Response.ContentListener
onContent
-
Methods inherited from interface org.eclipse.jetty.client.api.Response.DemandedContentListener
onBeforeContent
-
Methods inherited from interface org.eclipse.jetty.client.api.Response.Listener
onBegin, onFailure, onHeader, onSuccess
-
-
-
-
Constructor Detail
-
BufferingResponseListener
public BufferingResponseListener()
Deprecated.Creates an instance with a default maximum length of 2 MiB.
-
BufferingResponseListener
public BufferingResponseListener(int maxLength)
Deprecated.Creates an instance with the given maximum length- Parameters:
maxLength
- the maximum length of the content
-
-
Method Detail
-
onHeaders
public void onHeaders(Response response)
Deprecated.Description copied from interface:Response.HeadersListener
Callback method invoked when all the response headers have been received and parsed.- Parameters:
response
- the response containing the response line data and the headers
-
onContent
public void onContent(Response response, java.nio.ByteBuffer content)
Deprecated.Description copied from interface:Response.ContentListener
Callback method invoked when the response content has been received, parsed and there is demand. This method may be invoked multiple times, and thecontent
buffer must be consumed (or copied) before returning from this method.- Parameters:
response
- the response containing the response line data and the headerscontent
- the content bytes received
-
onComplete
public abstract void onComplete(Result result)
Deprecated.Description copied from interface:Response.CompleteListener
Callback method invoked when the request and the response have been processed, either successfully or not.The
result
parameter contains the request, the response, and eventual failures.Requests may complete after response, for example in case of big uploads that are discarded or read asynchronously by the server. This method is always invoked after
Response.SuccessListener.onSuccess(Response)
orResponse.FailureListener.onFailure(Response, Throwable)
, and only when request indicates that it is completed.- Parameters:
result
- the result of the request / response exchange
-
getMediaType
public java.lang.String getMediaType()
Deprecated.
-
getEncoding
public java.lang.String getEncoding()
Deprecated.
-
getContent
public byte[] getContent()
Deprecated.- Returns:
- the content as bytes
- See Also:
getContentAsString()
-
getContentAsString
public java.lang.String getContentAsString()
Deprecated.- 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)
Deprecated.- 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)
Deprecated.- 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()
Deprecated.- Returns:
- Content as InputStream
-
-