Class Http2Writer

java.lang.Object
org.miaixz.bus.http.metric.http.Http2Writer
All Implemented Interfaces:
Closeable, AutoCloseable

public class Http2Writer extends Object implements Closeable
编写HTTP/2传输帧.
Since:
Java 17+
Author:
Kimi Liu
  • Method Details

    • connectionPreface

      public void connectionPreface() throws IOException
      Throws:
      IOException
    • applyAndAckSettings

      public void applyAndAckSettings(Http2Settings peerSettings) throws IOException
      Applies peerSettings and then sends a settings ACK.
      Throws:
      IOException
    • pushPromise

      public void pushPromise(int streamId, int promisedStreamId, List<Http2Header> requestHeaders) throws IOException
      HTTP/2 only. 发送推送header 推送promise包含所有与服务器发起的请求相关的头信息,以及一个promise edstreamid, 它将传递响应帧。推送承诺帧作为响应的一部分发送到streamIdpromisedStreamId的 优先级比streamId大1
      Parameters:
      streamId - 客户端发起的流ID。必须是奇数.
      promisedStreamId - 服务器发起的流ID。必须是偶数.
      requestHeaders - 最低限度包括 :method, :scheme, :authority, and :path.
      Throws:
      IOException - 异常
    • flush

      public void flush() throws IOException
      Throws:
      IOException
    • rstStream

      public void rstStream(int streamId, Http2ErrorCode errorCode) throws IOException
      Throws:
      IOException
    • maxDataLength

      public int maxDataLength()
      The maximum size of bytes that may be sent in a single call to data(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.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 source.length and maxDataLength().
      Throws:
      IOException
    • settings

      public void settings(Http2Settings settings) throws IOException
      Write httpd's settings to the peer.
      Throws:
      IOException
    • ping

      public void ping(boolean ack, int payload1, int payload2) throws IOException
      Send a connection-level ping to the peer. ack indicates this is a reply. The data in payload1 and payload2 opaque binary, and there are no rules on the content.
      Throws:
      IOException
    • goAway

      public void goAway(int lastGoodStreamId, Http2ErrorCode errorCode, byte[] debugData) throws IOException
      告诉对方停止创建流,我们最后处理lastGoodStreamId,如果没有处理流,则为零.
      Parameters:
      lastGoodStreamId - 处理的最后一个流ID,如果没有处理流,则为零
      errorCode - 关闭连接的原因.
      debugData - 只适用于HTTP/2;要发送的不透明调试数据.
      Throws:
      IOException
    • windowUpdate

      public 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
    • frameHeader

      public void frameHeader(int streamId, int length, byte type, byte flags) throws IOException
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • headers

      public void headers(boolean outFinished, int streamId, List<Http2Header> headerBlock) throws IOException
      Throws:
      IOException