public final class Http2Stream
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
(package private) class |
Http2Stream.FramingSink
A sink that writes outgoing data frames of a stream.
|
private class |
Http2Stream.FramingSource
A source that reads the incoming data frames of a stream.
|
(package private) class |
Http2Stream.StreamTimeout
The Okio timeout watchdog will call
Http2Stream.StreamTimeout.timedOut() if the timeout is reached. |
Modifier and Type | Field and Description |
---|---|
(package private) long |
bytesLeftInWriteWindow
Count of bytes that can be written on the stream before receiving a window update.
|
(package private) Http2Connection |
connection |
(package private) ErrorCode |
errorCode
The reason why this stream was abnormally closed.
|
private boolean |
hasResponseHeaders
True if response headers have been sent or received.
|
(package private) int |
id |
(package private) Http2Stream.StreamTimeout |
readTimeout |
private java.util.List<Header> |
requestHeaders
Request headers.
|
private java.util.List<Header> |
responseHeaders
Response headers yet to be taken.
|
(package private) Http2Stream.FramingSink |
sink |
private Http2Stream.FramingSource |
source |
(package private) long |
unacknowledgedBytesRead
The total number of bytes consumed by the application (with
Http2Stream.FramingSource.read(okio.Buffer, long) ), but
not yet acknowledged by sending a WINDOW_UPDATE frame on this stream. |
(package private) Http2Stream.StreamTimeout |
writeTimeout |
Constructor and Description |
---|
Http2Stream(int id,
Http2Connection connection,
boolean outFinished,
boolean inFinished,
java.util.List<Header> requestHeaders) |
Modifier and Type | Method and Description |
---|---|
(package private) void |
addBytesToWriteWindow(long delta)
delta will be negative if a settings frame initial window is smaller than the last. |
(package private) void |
cancelStreamIfNecessary() |
(package private) void |
checkOutNotClosed() |
void |
close(ErrorCode rstStatusCode)
Abnormally terminate this stream.
|
private boolean |
closeInternal(ErrorCode errorCode)
Returns true if this stream was closed.
|
void |
closeLater(ErrorCode errorCode)
Abnormally terminate this stream.
|
Http2Connection |
getConnection() |
ErrorCode |
getErrorCode()
Returns the reason why this stream was closed, or null if it closed normally or has not yet
been closed.
|
int |
getId() |
java.util.List<Header> |
getRequestHeaders() |
okio.Sink |
getSink()
Returns a sink that can be used to write data to the peer.
|
okio.Source |
getSource()
Returns a source that reads data from the peer.
|
boolean |
isLocallyInitiated()
Returns true if this stream was created by this peer.
|
boolean |
isOpen()
Returns true if this stream is open.
|
okio.Timeout |
readTimeout() |
(package private) void |
receiveData(okio.BufferedSource in,
int length) |
(package private) void |
receiveFin() |
(package private) void |
receiveHeaders(java.util.List<Header> headers) |
(package private) void |
receiveRstStream(ErrorCode errorCode) |
void |
sendResponseHeaders(java.util.List<Header> responseHeaders,
boolean out)
Sends a reply to an incoming stream.
|
java.util.List<Header> |
takeResponseHeaders()
Removes and returns the stream's received response headers, blocking if necessary until headers
have been received.
|
(package private) void |
waitForIo()
Like
Object.wait(long) , but throws an InterruptedIOException when interrupted instead of
the more awkward InterruptedException . |
okio.Timeout |
writeTimeout() |
long unacknowledgedBytesRead
Http2Stream.FramingSource.read(okio.Buffer, long)
), but
not yet acknowledged by sending a WINDOW_UPDATE
frame on this stream.long bytesLeftInWriteWindow
connection.bytesLeftInWriteWindow
.final int id
final Http2Connection connection
private final java.util.List<Header> requestHeaders
private boolean hasResponseHeaders
private final Http2Stream.FramingSource source
final Http2Stream.FramingSink sink
final Http2Stream.StreamTimeout readTimeout
final Http2Stream.StreamTimeout writeTimeout
ErrorCode errorCode
Http2Stream(int id, Http2Connection connection, boolean outFinished, boolean inFinished, java.util.List<Header> requestHeaders)
public int getId()
public boolean isOpen()
SYN_RESET
frame abnormally terminates the stream.
Note that the input stream may continue to yield data even after a stream reports itself as not open. This is because input data is buffered.
public boolean isLocallyInitiated()
public Http2Connection getConnection()
public java.util.List<Header> getRequestHeaders()
public java.util.List<Header> takeResponseHeaders() throws java.io.IOException
java.io.IOException
public ErrorCode getErrorCode()
public void sendResponseHeaders(java.util.List<Header> responseHeaders, boolean out) throws java.io.IOException
out
- true to create an output stream that we can use to send data to the remote peer.
Corresponds to FLAG_FIN
.java.io.IOException
public okio.Timeout readTimeout()
public okio.Timeout writeTimeout()
public okio.Source getSource()
public okio.Sink getSink()
java.lang.IllegalStateException
- if this stream was initiated by the peer and a sendResponseHeaders(java.util.List<okhttp3.internal.http2.Header>, boolean)
has not yet been sent.public void close(ErrorCode rstStatusCode) throws java.io.IOException
RST_STREAM
frame has been
transmitted.java.io.IOException
public void closeLater(ErrorCode errorCode)
RST_STREAM
frame and returns
immediately.private boolean closeInternal(ErrorCode errorCode)
void receiveHeaders(java.util.List<Header> headers)
void receiveData(okio.BufferedSource in, int length) throws java.io.IOException
java.io.IOException
void receiveFin()
void receiveRstStream(ErrorCode errorCode)
void cancelStreamIfNecessary() throws java.io.IOException
java.io.IOException
void addBytesToWriteWindow(long delta)
delta
will be negative if a settings frame initial window is smaller than the last.void checkOutNotClosed() throws java.io.IOException
java.io.IOException
void waitForIo() throws java.io.InterruptedIOException
Object.wait(long)
, but throws an InterruptedIOException
when interrupted instead of
the more awkward InterruptedException
.java.io.InterruptedIOException