Module bus.http

Class Http2Codec

java.lang.Object
org.miaixz.bus.http.metric.http.Http2Codec
All Implemented Interfaces:
HttpCodec

public class Http2Codec extends Object implements HttpCodec
使用HTTP/2帧对请求和响应进行编码.
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

  • Method Details

    • http2HeadersList

      public static List<Http2Header> http2HeadersList(Request request)
    • readHttp2HeadersList

      public static Response.Builder readHttp2HeadersList(Headers headerBlock, org.miaixz.bus.core.net.Protocol protocol) throws IOException
      Returns headers for a name value block containing an HTTP/2 response.
      Throws:
      IOException
    • connection

      public RealConnection connection()
      Description copied from interface: HttpCodec
      返回携带此编解码器的连接
      Specified by:
      connection in interface HttpCodec
    • createRequestBody

      public org.miaixz.bus.core.io.sink.Sink createRequestBody(Request request, long contentLength)
      Description copied from interface: HttpCodec
      返回一个可以对请求体进行流处理的输出流.
      Specified by:
      createRequestBody in interface HttpCodec
      Parameters:
      request - 网络请求
      contentLength - 内容长度
      Returns:
      缓冲信息
    • writeRequestHeaders

      public void writeRequestHeaders(Request request) throws IOException
      Description copied from interface: HttpCodec
      这应该更新HTTP引擎的sentRequestMillis字段.
      Specified by:
      writeRequestHeaders in interface HttpCodec
      Parameters:
      request - 网络请求
      Throws:
      IOException - 异常
    • flushRequest

      public void flushRequest() throws IOException
      Description copied from interface: HttpCodec
      将请求刷新到基础套接字
      Specified by:
      flushRequest in interface HttpCodec
      Throws:
      IOException - 异常
    • finishRequest

      public void finishRequest() throws IOException
      Description copied from interface: HttpCodec
      将请求刷新到基础套接字,就不会传输更多的字节.
      Specified by:
      finishRequest in interface HttpCodec
      Throws:
      IOException - 异常
    • readResponseHeaders

      public Response.Builder readResponseHeaders(boolean expectContinue) throws IOException
      Description copied from interface: HttpCodec
      从HTTP传输解析响应头的字节
      Specified by:
      readResponseHeaders in interface HttpCodec
      Parameters:
      expectContinue - 如果这是一个带有“100”响应代码的中间响应, 则返回null。否则,此方法永远不会返回null.
      Returns:
      响应构建器
      Throws:
      IOException - 异常
    • reportedContentLength

      public long reportedContentLength(Response response)
      Specified by:
      reportedContentLength in interface HttpCodec
    • openResponseBodySource

      public org.miaixz.bus.core.io.source.Source openResponseBodySource(Response response)
      Specified by:
      openResponseBodySource in interface HttpCodec
    • trailers

      public Headers trailers() throws IOException
      Description copied from interface: HttpCodec
      在HTTP响应之后返回
      Specified by:
      trailers in interface HttpCodec
      Returns:
      the object
      Throws:
      IOException - 异常
    • cancel

      public void cancel()
      Description copied from interface: HttpCodec
      取消这个流。这个流所持有的资源将被清理,尽管不是同步的。这可能会在连接池线程之后发生
      Specified by:
      cancel in interface HttpCodec