Interface PushObserver
-
public interface PushObserverHTTP/2only. Processes server-initiated HTTP requests on the client. Implementations must quickly dispatch callbacks to avoid creating a bottleneck.While
onReset(int, com.squareup.okhttp.internal.framed.ErrorCode)may occur at any time, the following callbacks are expected in order, correlated by stream ID.onRequest(int, java.util.List<com.squareup.okhttp.internal.framed.Header>)onHeaders(int, java.util.List<com.squareup.okhttp.internal.framed.Header>, boolean)(unless canceled)onData(int, okio.BufferedSource, int, boolean)(optional sequence of data frames)
As a stream ID is scoped to a single HTTP/2 connection, implementations which target multiple connections should expect repetition of stream IDs.
Return true to request cancellation of a pushed stream. Note that this does not guarantee future frames won't arrive on the stream ID.
-
-
Field Summary
Fields Modifier and Type Field Description static PushObserverCANCEL
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanonData(int streamId, BufferedSource source, int byteCount, boolean last)A chunk of response data corresponding to a pushed request.booleanonHeaders(int streamId, List<Header> responseHeaders, boolean last)The response headers corresponding to a pushed request.booleanonRequest(int streamId, List<Header> requestHeaders)Describes the request that the server intends to push a response for.voidonReset(int streamId, ErrorCode errorCode)Indicates the reason why this stream was canceled.
-
-
-
Field Detail
-
CANCEL
static final PushObserver CANCEL
-
-
Method Detail
-
onRequest
boolean onRequest(int streamId, List<Header> requestHeaders)Describes the request that the server intends to push a response for.- Parameters:
streamId- server-initiated stream ID: an even number.requestHeaders- minimally includes:method,:scheme,:authority, and (@code :path}.
-
onHeaders
boolean onHeaders(int streamId, List<Header> responseHeaders, boolean last)The response headers corresponding to a pushed request. Whenlastis true, there are no data frames to follow.- Parameters:
streamId- server-initiated stream ID: an even number.responseHeaders- minimally includes:status.last- when true, there is no response data.
-
onData
boolean onData(int streamId, BufferedSource source, int byteCount, boolean last) throws IOExceptionA chunk of response data corresponding to a pushed request. This data must either be read or skipped.- Parameters:
streamId- server-initiated stream ID: an even number.source- location of data corresponding with this stream ID.byteCount- number of bytes to read or skip from the source.last- when true, there are no data frames to follow.- Throws:
IOException
-
onReset
void onReset(int streamId, ErrorCode errorCode)Indicates the reason why this stream was canceled.
-
-