Package org.miaixz.bus.http.metric.http
Class Http2Writer
java.lang.Object
org.miaixz.bus.http.metric.http.Http2Writer
- All Implemented Interfaces:
Closeable,AutoCloseable
编写HTTP/2传输帧.
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Method Summary
Modifier and TypeMethodDescriptionvoidapplyAndAckSettings(Settings peerSettings) AppliespeerSettingsand then sends a settings ACK.voidclose()voidvoiddata(boolean outFinished, int streamId, org.miaixz.bus.core.io.buffer.Buffer source, int byteCount) source.lengthmay be longer than the max length of the variant's data frame.voidflush()voidframeHeader(int streamId, int length, byte type, byte flags) void告诉对方停止创建流,我们最后处理lastGoodStreamId,如果没有处理流,则为零.voidheaders(boolean outFinished, int streamId, List<Headers.Header> headerBlock) intThe maximum size of bytes that may be sent in a single call todata(boolean, int, org.miaixz.bus.core.io.buffer.Buffer, int).voidping(boolean ack, int payload1, int payload2) Send a connection-level ping to the peer.voidpushPromise(int streamId, int promisedStreamId, List<Headers.Header> requestHeaders) HTTP/2 only.voidvoidWrite httpd's settings to the peer.voidwindowUpdate(int streamId, long windowSizeIncrement) Inform peer that an additionalwindowSizeIncrementbytes can be sent onstreamId, or the connection ifstreamIdis zero.
-
Method Details
-
connectionPreface
- Throws:
IOException
-
applyAndAckSettings
AppliespeerSettingsand then sends a settings ACK.- Throws:
IOException
-
pushPromise
public void pushPromise(int streamId, int promisedStreamId, List<Headers.Header> requestHeaders) throws IOException HTTP/2 only. 发送推送header 推送promise包含所有与服务器发起的请求相关的头信息,以及一个promise edstreamid, 它将传递响应帧。推送承诺帧作为响应的一部分发送到streamId。promisedStreamId的 优先级比streamId大1- Parameters:
streamId- 客户端发起的流ID。必须是奇数.promisedStreamId- 服务器发起的流ID。必须是偶数.requestHeaders- 最低限度包括:method,:scheme,:authority, and:path.- Throws:
IOException- 异常
-
flush
- Throws:
IOException
-
rstStream
- Throws:
IOException
-
maxDataLength
public int maxDataLength()The maximum size of bytes that may be sent in a single call todata(boolean, int, org.miaixz.bus.core.io.buffer.Buffer, int). -
data
public void data(boolean outFinished, int streamId, org.miaixz.bus.core.io.buffer.Buffer source, int byteCount) throws IOException source.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 ofsource.lengthandmaxDataLength().- Throws:
IOException
-
settings
Write httpd's settings to the peer.- Throws:
IOException
-
ping
Send a connection-level ping to the peer.ackindicates this is a reply. The data inpayload1andpayload2opaque binary, and there are no rules on the content.- Throws:
IOException
-
goAway
告诉对方停止创建流,我们最后处理lastGoodStreamId,如果没有处理流,则为零.- Parameters:
lastGoodStreamId- 处理的最后一个流ID,如果没有处理流,则为零errorCode- 关闭连接的原因.debugData- 只适用于HTTP/2;要发送的不透明调试数据.- Throws:
IOException
-
windowUpdate
Inform peer that an additionalwindowSizeIncrementbytes can be sent onstreamId, or the connection ifstreamIdis zero.- Throws:
IOException
-
frameHeader
- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
headers
public void headers(boolean outFinished, int streamId, List<Headers.Header> headerBlock) throws IOException - Throws:
IOException
-