Interface HttpCodec

All Known Implementing Classes:
Http1Codec, Http2Codec

public interface HttpCodec
Encode HTTP请求和decode HTTP响应
Since:
Java 17+
Author:
Kimi Liu
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    丢弃输入数据流时要使用的超时。由于这是用于连接重用, 因此此超时时间应该大大少于建立新连接所需的时间.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    取消这个流。这个流所持有的资源将被清理,尽管不是同步的。这可能会在连接池线程之后发生
    返回携带此编解码器的连接
    org.miaixz.bus.core.io.sink.Sink
    createRequestBody(Request request, long contentLength)
    返回一个可以对请求体进行流处理的输出流.
    void
    将请求刷新到基础套接字,就不会传输更多的字节.
    void
    将请求刷新到基础套接字
    org.miaixz.bus.core.io.source.Source
     
    readResponseHeaders(boolean expectContinue)
    从HTTP传输解析响应头的字节
    long
     
    在HTTP响应之后返回
    void
    这应该更新HTTP引擎的sentRequestMillis字段.
  • Field Details

    • DISCARD_STREAM_TIMEOUT_MILLIS

      static final int DISCARD_STREAM_TIMEOUT_MILLIS
      丢弃输入数据流时要使用的超时。由于这是用于连接重用, 因此此超时时间应该大大少于建立新连接所需的时间.
      See Also:
  • Method Details

    • connection

      RealConnection connection()
      返回携带此编解码器的连接
    • createRequestBody

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

      void writeRequestHeaders(Request request) throws IOException
      这应该更新HTTP引擎的sentRequestMillis字段.
      Parameters:
      request - 网络请求
      Throws:
      IOException - 异常
    • flushRequest

      void flushRequest() throws IOException
      将请求刷新到基础套接字
      Throws:
      IOException - 异常
    • finishRequest

      void finishRequest() throws IOException
      将请求刷新到基础套接字,就不会传输更多的字节.
      Throws:
      IOException - 异常
    • readResponseHeaders

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

      long reportedContentLength(Response response) throws IOException
      Throws:
      IOException
    • openResponseBodySource

      org.miaixz.bus.core.io.source.Source openResponseBodySource(Response response) throws IOException
      Throws:
      IOException
    • trailers

      Headers trailers() throws IOException
      在HTTP响应之后返回
      Returns:
      the object
      Throws:
      IOException - 异常
    • cancel

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