Class HttpReceiverOverHTTP3
- All Implemented Interfaces:
Stream.Client.Listener
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected HttpChannelOverHTTP3
void
onDataAvailable
(Stream.Client stream) Callback method invoked if the application has expresseddemand
for content, and if there may be content available.void
onFailure
(Stream.Client stream, long error, Throwable failure) Callback method invoked when a stream failure occurred.boolean
onIdleTimeout
(Stream.Client stream, Throwable failure) Callback method invoked when the stream idle timeout elapses.void
onResponse
(Stream.Client stream, HeadersFrame frame) Callback method invoked when a response is received.void
onTrailer
(Stream.Client stream, HeadersFrame frame) Callback method invoked when a trailer is received.protected void
receive()
protected void
reset()
Resets the state of this HttpReceiver.Methods inherited from class org.eclipse.jetty.client.HttpReceiver
abort, demand, dispose, getHttpDestination, getHttpExchange, hasDemandOrStall, isFailed, responseBegin, responseContent, responseFailure, responseHeader, responseHeaders, responseSuccess, storeCookie, toString
-
Constructor Details
-
HttpReceiverOverHTTP3
-
-
Method Details
-
getHttpChannel
- Overrides:
getHttpChannel
in classHttpReceiver
-
receive
protected void receive()- Overrides:
receive
in classHttpReceiver
-
onResponse
Description copied from interface:Stream.Client.Listener
Callback method invoked when a response is received.
To read response content, applications should call
Stream.demand()
and overrideStream.Client.Listener.onDataAvailable(Client)
.- Specified by:
onResponse
in interfaceStream.Client.Listener
- Parameters:
stream
- the streamframe
- the HEADERS frame containing the response headers- See Also:
-
onDataAvailable
Description copied from interface:Stream.Client.Listener
Callback method invoked if the application has expressed
demand
for content, and if there may be content available.A server application that wishes to handle request content should typically call
Stream.demand()
fromSession.Server.Listener.onRequest(Server, HeadersFrame)
.A client application that wishes to handle response content should typically call
Stream.demand()
fromStream.Client.Listener.onResponse(Client, HeadersFrame)
.Just prior calling this method, the outstanding demand is cancelled; applications that implement this method should read content calling
Stream.readData()
, and callStream.demand()
to signal to the implementation to call again this method when there may be more content available.Only one thread at a time invokes this method, although it may not be the same thread across different invocations.
It is always guaranteed that invoking
Stream.demand()
from within this method will not cause aStackOverflowError
.Typical usage:
class MyStreamListener implements Stream.Client.Listener { @Override public void onDataAvailable(Stream.Client stream) { // Read a chunk of the content. Stream.Data data = stream.readData(); if (data == null) { // No data available now, demand to be called back. stream.demand(); } else { // Process the content. process(data.getByteBuffer()); // Notify that the content has been consumed. data.complete(); if (!data.isLast()) { // Demand to be called back. stream.demand(); } } } }
- Specified by:
onDataAvailable
in interfaceStream.Client.Listener
- Parameters:
stream
- the stream
-
onTrailer
Description copied from interface:Stream.Client.Listener
Callback method invoked when a trailer is received.
- Specified by:
onTrailer
in interfaceStream.Client.Listener
- Parameters:
stream
- the streamframe
- the HEADERS frame containing the trailer headers
-
onIdleTimeout
Description copied from interface:Stream.Client.Listener
Callback method invoked when the stream idle timeout elapses.
- Specified by:
onIdleTimeout
in interfaceStream.Client.Listener
- Parameters:
stream
- the streamfailure
- the timeout failure- Returns:
- true to reset the stream, false to ignore the idle timeout
-
onFailure
Description copied from interface:Stream.Client.Listener
Callback method invoked when a stream failure occurred.
Typical stream failures, among others, are failures to decode a HEADERS frame, or failures to read bytes because the stream has been reset.
- Specified by:
onFailure
in interfaceStream.Client.Listener
- Parameters:
stream
- the streamerror
- the failure errorfailure
- the cause of the failure
-
reset
protected void reset()Description copied from class:HttpReceiver
Resets the state of this HttpReceiver.Subclasses should override (but remember to call
super
) to reset their own state.Either this method or
HttpReceiver.dispose()
is called.- Overrides:
reset
in classHttpReceiver
-