public interface PushObserver
An interface for handling server-initiated HTTP requests, specific to
HTTP/2.
Implementations of this interface can choose to cancel pushed streams by returning true. Note that this does
not guarantee that future frames will not arrive for the canceled stream ID.
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PushObserverA push observer that cancels all incoming pushed streams. -
Method Summary
Modifier and TypeMethodDescriptionbooleanonData(int streamId, org.miaixz.bus.core.io.source.BufferSource source, int byteCount, boolean last) A block of response data corresponding to the pushed request.booleanonHeaders(int streamId, List<Http2Header> responseHeaders, boolean last) The response headers corresponding to the pushed request.booleanonRequest(int streamId, List<Http2Header> requestHeaders) Describes the request that the server intends to push a response for.voidonReset(int streamId, Http2ErrorCode errorCode) Indicates the reason why this stream was canceled.
-
Field Details
-
CANCEL
A push observer that cancels all incoming pushed streams.
-
-
Method Details
-
onRequest
Describes the request that the server intends to push a response for.- Parameters:
streamId- The server-initiated stream ID, which will be an even number.requestHeaders- The request headers, minimally including method, scheme, authority, and path.- Returns:
trueto cancel the pushed stream,falseto accept it.
-
onHeaders
The response headers corresponding to the pushed request. Whenlastis true, there are no subsequent data frames.- Parameters:
streamId- The server-initiated stream ID, which will be an even number.responseHeaders- The response headers, minimally including the status.last-trueif there is no response data.- Returns:
trueto cancel the pushed stream,falseto accept it.
-
onData
boolean onData(int streamId, org.miaixz.bus.core.io.source.BufferSource source, int byteCount, boolean last) throws IOException A block of response data corresponding to the pushed request. This data must be read or skipped.- Parameters:
streamId- The server-initiated stream ID, which will be an even number.source- The source of the data corresponding to this stream ID.byteCount- The number of bytes to read or skip from the source.last-trueif no more data frames will follow.- Returns:
trueto cancel the pushed stream,falseto accept it.- Throws:
IOException- if an I/O error occurs.
-
onReset
Indicates the reason why this stream was canceled.- Parameters:
streamId- The server-initiated stream ID, which will be an even number.errorCode- The error code indicating the reason for cancellation.
-