Interface FrameWriter

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void ackSettings​(Settings peerSettings)
      Informs the peer that we've applied its latest settings.
      void connectionPreface()
      HTTP/2 only.
      void data​(boolean outFinished, int streamId, Buffer source, int byteCount)
      source.length may be longer than the max length of the variant's data frame.
      void flush()
      SPDY/3 only.
      void goAway​(int lastGoodStreamId, ErrorCode errorCode, byte[] debugData)
      Tell the peer to stop creating streams and that we last processed lastGoodStreamId, or zero if no streams were processed.
      void headers​(int streamId, List<Header> headerBlock)  
      int maxDataLength()
      The maximum size of bytes that may be sent in a single call to data(boolean, int, okio.Buffer, int).
      void ping​(boolean ack, int payload1, int payload2)
      Send a connection-level ping to the peer.
      void pushPromise​(int streamId, int promisedStreamId, List<Header> requestHeaders)
      HTTP/2 only.
      void rstStream​(int streamId, ErrorCode errorCode)  
      void settings​(Settings okHttpSettings)
      Write okhttp's settings to the peer.
      void synReply​(boolean outFinished, int streamId, List<Header> headerBlock)  
      void synStream​(boolean outFinished, boolean inFinished, int streamId, int associatedStreamId, List<Header> headerBlock)  
      void windowUpdate​(int streamId, long windowSizeIncrement)
      Inform peer that an additional windowSizeIncrement bytes can be sent on streamId, or the connection if streamId is zero.
    • Method Detail

      • ackSettings

        void ackSettings​(Settings peerSettings)
                  throws IOException
        Informs the peer that we've applied its latest settings.
        Throws:
        IOException
      • pushPromise

        void pushPromise​(int streamId,
                         int promisedStreamId,
                         List<Header> requestHeaders)
                  throws IOException
        HTTP/2 only. Send a push promise header block.

        A push promise contains all the headers that pertain to a server-initiated request, and a promisedStreamId to which response frames will be delivered. Push promise frames are sent as a part of the response to streamId. The promisedStreamId has a priority of one greater than streamId.

        Parameters:
        streamId - client-initiated stream ID. Must be an odd number.
        promisedStreamId - server-initiated stream ID. Must be an even number.
        requestHeaders - minimally includes :method, :scheme, :authority, and (@code :path}.
        Throws:
        IOException
      • synStream

        void synStream​(boolean outFinished,
                       boolean inFinished,
                       int streamId,
                       int associatedStreamId,
                       List<Header> headerBlock)
                throws IOException
        Throws:
        IOException
      • data

        void data​(boolean outFinished,
                  int streamId,
                  Buffer source,
                  int byteCount)
           throws IOException
        source.length may be longer than the max length of the variant's data frame. Implementations must send multiple frames as necessary.
        Parameters:
        source - the buffer to draw bytes from. May be null if byteCount is 0.
        byteCount - must be between 0 and the minimum of {code source.length} and maxDataLength().
        Throws:
        IOException
      • ping

        void ping​(boolean ack,
                  int payload1,
                  int payload2)
           throws IOException
        Send a connection-level ping to the peer. ack indicates this is a reply. Payload parameters are different between SPDY/3 and HTTP/2.

        In SPDY/3, only the first payload1 parameter is sent. If the sender is a client, it is an unsigned odd number. Likewise, a server will send an even number.

        In HTTP/2, both payload1 and payload2 parameters are sent. The data is opaque binary, and there are no rules on the content.

        Throws:
        IOException
      • goAway

        void goAway​(int lastGoodStreamId,
                    ErrorCode errorCode,
                    byte[] debugData)
             throws IOException
        Tell the peer to stop creating streams and that we last processed lastGoodStreamId, or zero if no streams were processed.
        Parameters:
        lastGoodStreamId - the last stream ID processed, or zero if no streams were processed.
        errorCode - reason for closing the connection.
        debugData - only valid for HTTP/2; opaque debug data to send.
        Throws:
        IOException
      • windowUpdate

        void windowUpdate​(int streamId,
                          long windowSizeIncrement)
                   throws IOException
        Inform peer that an additional windowSizeIncrement bytes can be sent on streamId, or the connection if streamId is zero.
        Throws:
        IOException