public interface PushObserver
HTTP/2
only.
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.
Modifier and Type | Field and Description |
---|---|
static PushObserver |
CANCEL |
Modifier and Type | Method and Description |
---|---|
boolean |
onData(int streamId,
okio.BufferedSource source,
int byteCount,
boolean last)
A chunk of response data corresponding to a pushed request.
|
boolean |
onHeaders(int streamId,
List<Header> responseHeaders,
boolean last)
The response headers corresponding to a pushed request.
|
boolean |
onRequest(int streamId,
List<Header> requestHeaders)
Describes the request that the server intends to push a response for.
|
void |
onReset(int streamId,
ErrorCode errorCode)
Indicates the reason why this stream was canceled.
|
static final PushObserver CANCEL
boolean onRequest(int streamId, List<Header> requestHeaders)
streamId
- server-initiated stream ID: an even number.requestHeaders
- minimally includes :method
, :scheme
,
:authority
, and (@code :path}.boolean onHeaders(int streamId, List<Header> responseHeaders, boolean last)
last
is true, there are no data frames to follow.streamId
- server-initiated stream ID: an even number.responseHeaders
- minimally includes :status
.last
- when true, there is no response data.boolean onData(int streamId, okio.BufferedSource source, int byteCount, boolean last) throws IOException
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.IOException
void onReset(int streamId, ErrorCode errorCode)
Copyright © 2017. All Rights Reserved.