Class SpdyStream

java.lang.Object
com.squareup.okhttp.internal.spdy.SpdyStream

public final class SpdyStream
extends Object
A logical bidirectional stream.
  • 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_THRESHOLD
      The number of unacknowledged bytes at which the input stream will send the peer a WINDOW_UPDATE frame. 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_RESET frame abnormally terminates the stream.
      • Both input and output streams have transmitted all data and headers.
      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.
    • isLocallyInitiated

      public boolean isLocallyInitiated()
      Returns true if this stream was created by this peer.
    • getConnection

      public SpdyConnection getConnection()
    • getRequestHeaders

      public List<String> getRequestHeaders()
    • getResponseHeaders

      public List<String> getResponseHeaders() throws IOException
      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 are RST_PROTOCOL_ERROR, RST_INVALID_STREAM, RST_REFUSED_STREAM, RST_UNSUPPORTED_VERSION, RST_CANCEL, RST_INTERNAL_ERROR and RST_FLOW_CONTROL_ERROR.
    • reply

      public void reply​(List<String> 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 to FLAG_FIN.
      Throws:
      IOException
    • setReadTimeout

      public void setReadTimeout​(long readTimeoutMillis)
      Sets the maximum time to wait on input stream reads before failing with a SocketTimeoutException, or 0 to wait indefinitely.
    • getReadTimeoutMillis

      public long getReadTimeoutMillis()
    • getInputStream

      public InputStream getInputStream()
      Returns an input stream that can be used to read data from the peer.
    • getOutputStream

      public OutputStream 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 a reply(java.util.List<java.lang.String>, boolean) has not yet been sent.
    • close

      public void close​(int rstStatusCode) throws IOException
      Abnormally terminate this stream. This blocks until the RST_STREAM frame has been transmitted.
      Throws:
      IOException
    • closeLater

      public void closeLater​(int rstStatusCode)
      Abnormally terminate this stream. This enqueues a RST_STREAM frame and returns immediately.