Class SpdyStream
java.lang.Object
com.squareup.okhttp.internal.spdy.SpdyStream
public final class SpdyStream extends Object
A logical bidirectional stream.
-
Field Summary
Fields Modifier and Type Field Description static intRST_CANCELstatic intRST_FLOW_CONTROL_ERRORstatic intRST_FRAME_TOO_LARGEstatic intRST_INTERNAL_ERRORstatic intRST_INVALID_CREDENTIALSstatic intRST_INVALID_STREAMstatic intRST_PROTOCOL_ERRORstatic intRST_REFUSED_STREAMstatic intRST_STREAM_ALREADY_CLOSEDstatic intRST_STREAM_IN_USEstatic intRST_UNSUPPORTED_VERSIONstatic intWINDOW_UPDATE_THRESHOLDThe number of unacknowledged bytes at which the input stream will send the peer aWINDOW_UPDATEframe. -
Method Summary
Modifier and Type Method Description voidclose(int rstStatusCode)Abnormally terminate this stream.voidcloseLater(int rstStatusCode)Abnormally terminate this stream.SpdyConnectiongetConnection()InputStreamgetInputStream()Returns an input stream that can be used to read data from the peer.OutputStreamgetOutputStream()Returns an output stream that can be used to write data to the peer.longgetReadTimeoutMillis()List<String>getRequestHeaders()List<String>getResponseHeaders()Returns the stream's response headers, blocking if necessary if they have not been received yet.intgetRstStatusCode()Returns the reason why this stream was closed, or -1 if it closed normally or has not yet been closed.booleanisLocallyInitiated()Returns true if this stream was created by this peer.booleanisOpen()Returns true if this stream is open.voidreply(List<String> responseHeaders, boolean out)Sends a reply to an incoming stream.voidsetReadTimeout(long readTimeoutMillis)Sets the maximum time to wait on input stream reads before failing with aSocketTimeoutException, or0to wait indefinitely.
-
Field Details
-
RST_PROTOCOL_ERROR
public static final int RST_PROTOCOL_ERROR- See Also:
- Constant Field Values
-
RST_INVALID_STREAM
public static final int RST_INVALID_STREAM- See Also:
- Constant Field Values
-
RST_REFUSED_STREAM
public static final int RST_REFUSED_STREAM- See Also:
- Constant Field Values
-
RST_UNSUPPORTED_VERSION
public static final int RST_UNSUPPORTED_VERSION- See Also:
- Constant Field Values
-
RST_CANCEL
public static final int RST_CANCEL- See Also:
- Constant Field Values
-
RST_INTERNAL_ERROR
public static final int RST_INTERNAL_ERROR- See Also:
- Constant Field Values
-
RST_FLOW_CONTROL_ERROR
public static final int RST_FLOW_CONTROL_ERROR- See Also:
- Constant Field Values
-
RST_STREAM_IN_USE
public static final int RST_STREAM_IN_USE- See Also:
- Constant Field Values
-
RST_STREAM_ALREADY_CLOSED
public static final int RST_STREAM_ALREADY_CLOSED- See Also:
- Constant Field Values
-
RST_INVALID_CREDENTIALS
public static final int RST_INVALID_CREDENTIALS- See Also:
- Constant Field Values
-
RST_FRAME_TOO_LARGE
public static final int RST_FRAME_TOO_LARGE- See Also:
- Constant Field Values
-
WINDOW_UPDATE_THRESHOLD
public static final int WINDOW_UPDATE_THRESHOLDThe number of unacknowledged bytes at which the input stream will send the peer aWINDOW_UPDATEframe. Must be less than this client's window size, otherwise the remote peer will stop sending data on this stream. (Chrome 25 uses 5 MiB.)- See Also:
- Constant Field Values
-
-
Method Details
-
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
-
getRequestHeaders
-
getResponseHeaders
Returns the stream's response headers, blocking if necessary if they have not been received yet.- Throws:
IOException
-
getRstStatusCode
public int getRstStatusCode()Returns the reason why this stream was closed, or -1 if it closed normally or has not yet been closed. Valid reasons areRST_PROTOCOL_ERROR,RST_INVALID_STREAM,RST_REFUSED_STREAM,RST_UNSUPPORTED_VERSION,RST_CANCEL,RST_INTERNAL_ERRORandRST_FLOW_CONTROL_ERROR. -
reply
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
-
setReadTimeout
public void setReadTimeout(long readTimeoutMillis)Sets the maximum time to wait on input stream reads before failing with aSocketTimeoutException, or0to wait indefinitely. -
getReadTimeoutMillis
public long getReadTimeoutMillis() -
getInputStream
Returns an input stream that can be used to read data from the peer. -
getOutputStream
Returns an output stream 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<java.lang.String>, boolean)has not yet been sent.
-
close
Abnormally terminate this stream. This blocks until theRST_STREAMframe has been transmitted.- Throws:
IOException
-
closeLater
public void closeLater(int rstStatusCode)Abnormally terminate this stream. This enqueues aRST_STREAMframe and returns immediately.
-