Class FramedStream
- java.lang.Object
-
- com.squareup.okhttp.internal.framed.FramedStream
-
public final class FramedStream extends Object
A logical bidirectional stream.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose(ErrorCode rstStatusCode)Abnormally terminate this stream.voidcloseLater(ErrorCode errorCode)Abnormally terminate this stream.FramedConnectiongetConnection()ErrorCodegetErrorCode()Returns the reason why this stream was closed, or null if it closed normally or has not yet been closed.intgetId()List<Header>getRequestHeaders()List<Header>getResponseHeaders()Returns the stream's response headers, blocking if necessary if they have not been received yet.SinkgetSink()Returns a sink that can be used to write data to the peer.SourcegetSource()Returns a source that reads data from the peer.booleanisLocallyInitiated()Returns true if this stream was created by this peer.booleanisOpen()Returns true if this stream is open.TimeoutreadTimeout()voidreply(List<Header> responseHeaders, boolean out)Sends a reply to an incoming stream.TimeoutwriteTimeout()
-
-
-
Method Detail
-
getId
public int getId()
-
isOpen
public boolean isOpen()
Returns true if this stream is open. A stream is open until either:- A
SYN_RESETframe abnormally terminates the stream. - Both input and output streams have transmitted all data and headers.
- A
-
isLocallyInitiated
public boolean isLocallyInitiated()
Returns true if this stream was created by this peer.
-
getConnection
public FramedConnection getConnection()
-
getResponseHeaders
public List<Header> getResponseHeaders() throws IOException
Returns the stream's response headers, blocking if necessary if they have not been received yet.- Throws:
IOException
-
getErrorCode
public ErrorCode getErrorCode()
Returns the reason why this stream was closed, or null if it closed normally or has not yet been closed.
-
reply
public void reply(List<Header> responseHeaders, boolean out) throws IOException
Sends a reply to an incoming stream.- Parameters:
out- true to create an output stream that we can use to send data to the remote peer. Corresponds toFLAG_FIN.- Throws:
IOException
-
readTimeout
public Timeout readTimeout()
-
writeTimeout
public Timeout writeTimeout()
-
getSource
public Source getSource()
Returns a source that reads data from the peer.
-
getSink
public Sink getSink()
Returns a sink that can be used to write data to the peer.- Throws:
IllegalStateException- if this stream was initiated by the peer and areply(java.util.List<com.squareup.okhttp.internal.framed.Header>, boolean)has not yet been sent.
-
close
public void close(ErrorCode rstStatusCode) throws IOException
Abnormally terminate this stream. This blocks until theRST_STREAMframe has been transmitted.- Throws:
IOException
-
closeLater
public void closeLater(ErrorCode errorCode)
Abnormally terminate this stream. This enqueues aRST_STREAMframe and returns immediately.
-
-