Module bus.http

Class RealCall

java.lang.Object
org.miaixz.bus.http.RealCall
All Implemented Interfaces:
Cloneable, NewCall

public class RealCall extends Object implements NewCall
HTTP 请求的实际执行者

负责执行同步和异步 HTTP 请求,通过拦截器链处理请求和响应。 支持 WebSocket 连接、请求取消、超时管理和重试机制。

Since:
Java 17+
Author:
Kimi Liu
  • Field Details

    • client

      public final Httpd client
      HTTP 客户端
    • originalRequest

      public final Request originalRequest
      原始请求
    • forWebSocket

      public final boolean forWebSocket
      是否为 WebSocket 请求
    • transmitter

      public Transmitter transmitter
      请求传输器
    • executed

      public boolean executed
      是否已执行
  • Method Details

    • request

      public Request request()
      获取原始请求
      Specified by:
      request in interface NewCall
      Returns:
      原始请求
    • execute

      public Response execute() throws IOException
      同步执行请求
      Specified by:
      execute in interface NewCall
      Returns:
      响应
      Throws:
      IOException - 如果执行失败
      IllegalStateException - 如果请求已执行
    • enqueue

      public void enqueue(Callback responseCallback)
      异步执行请求
      Specified by:
      enqueue in interface NewCall
      Parameters:
      responseCallback - 响应回调
      Throws:
      IllegalStateException - 如果请求已执行
    • cancel

      public void cancel()
      取消请求
      Specified by:
      cancel in interface NewCall
    • timeout

      public org.miaixz.bus.core.io.timout.Timeout timeout()
      获取超时配置
      Specified by:
      timeout in interface NewCall
      Returns:
      超时配置
    • isExecuted

      public boolean isExecuted()
      检查是否已执行
      Specified by:
      isExecuted in interface NewCall
      Returns:
      true 如果已执行
    • isCanceled

      public boolean isCanceled()
      检查是否已取消
      Specified by:
      isCanceled in interface NewCall
      Returns:
      true 如果已取消
    • clone

      public RealCall clone()
      克隆 RealCall 实例
      Specified by:
      clone in interface NewCall
      Overrides:
      clone in class Object
      Returns:
      新的 RealCall 实例
    • toLoggableString

      public String toLoggableString()
      获取可记录的字符串表示
      Returns:
      描述调用的字符串(不包含完整 URL)
    • redactedUrl

      public String redactedUrl()
      获取隐藏敏感信息的 URL
      Returns:
      隐藏敏感信息的 URL
    • getResponseWithInterceptorChain

      public Response getResponseWithInterceptorChain() throws IOException
      通过拦截器链获取响应
      Returns:
      响应
      Throws:
      IOException - 如果执行失败