Interface FrameWriter
-
- All Superinterfaces:
AutoCloseable,Closeable
public interface FrameWriter extends Closeable
Writes transport frames for SPDY/3 or HTTP/2.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidackSettings(Settings peerSettings)Informs the peer that we've applied its latest settings.voidconnectionPreface()HTTP/2 only.voiddata(boolean outFinished, int streamId, Buffer source, int byteCount)source.lengthmay be longer than the max length of the variant's data frame.voidflush()SPDY/3 only.voidgoAway(int lastGoodStreamId, ErrorCode errorCode, byte[] debugData)Tell the peer to stop creating streams and that we last processedlastGoodStreamId, or zero if no streams were processed.voidheaders(int streamId, List<Header> headerBlock)intmaxDataLength()The maximum size of bytes that may be sent in a single call todata(boolean, int, okio.Buffer, int).voidping(boolean ack, int payload1, int payload2)Send a connection-level ping to the peer.voidpushPromise(int streamId, int promisedStreamId, List<Header> requestHeaders)HTTP/2 only.voidrstStream(int streamId, ErrorCode errorCode)voidsettings(Settings okHttpSettings)Write okhttp's settings to the peer.voidsynReply(boolean outFinished, int streamId, List<Header> headerBlock)voidsynStream(boolean outFinished, boolean inFinished, int streamId, int associatedStreamId, List<Header> headerBlock)voidwindowUpdate(int streamId, long windowSizeIncrement)Inform peer that an additionalwindowSizeIncrementbytes can be sent onstreamId, or the connection ifstreamIdis zero.
-
-
-
Method Detail
-
connectionPreface
void connectionPreface() throws IOExceptionHTTP/2 only.- Throws:
IOException
-
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 IOExceptionHTTP/2 only. Send a push promise header block.A push promise contains all the headers that pertain to a server-initiated request, and a
promisedStreamIdto which response frames will be delivered. Push promise frames are sent as a part of the response tostreamId. ThepromisedStreamIdhas a priority of one greater thanstreamId.- 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
-
flush
void flush() throws IOExceptionSPDY/3 only.- Throws:
IOException
-
synStream
void synStream(boolean outFinished, boolean inFinished, int streamId, int associatedStreamId, List<Header> headerBlock) throws IOException- Throws:
IOException
-
synReply
void synReply(boolean outFinished, int streamId, List<Header> headerBlock) throws IOException- Throws:
IOException
-
headers
void headers(int streamId, List<Header> headerBlock) throws IOException- Throws:
IOException
-
rstStream
void rstStream(int streamId, ErrorCode errorCode) throws IOException- Throws:
IOException
-
maxDataLength
int maxDataLength()
The maximum size of bytes that may be sent in a single call todata(boolean, int, okio.Buffer, int).
-
data
void data(boolean outFinished, int streamId, Buffer source, int byteCount) throws IOExceptionsource.lengthmay 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} andmaxDataLength().- Throws:
IOException
-
settings
void settings(Settings okHttpSettings) throws IOException
Write okhttp's settings to the peer.- Throws:
IOException
-
ping
void ping(boolean ack, int payload1, int payload2) throws IOExceptionSend a connection-level ping to the peer.ackindicates this is a reply. Payload parameters are different between SPDY/3 and HTTP/2.In SPDY/3, only the first
payload1parameter 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
payload1andpayload2parameters 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 IOExceptionTell the peer to stop creating streams and that we last processedlastGoodStreamId, 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 IOExceptionInform peer that an additionalwindowSizeIncrementbytes can be sent onstreamId, or the connection ifstreamIdis zero.- Throws:
IOException
-
-