Module bus.http

Class RealCall

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

public final class RealCall extends Object implements NewCall
The concrete implementation of an HTTP call.

This class is responsible for executing synchronous and asynchronous HTTP requests by processing them through an interceptor chain. It supports WebSocket connections, request cancellation, timeout management, and retry mechanisms.

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

    • client

      public final Httpd client
      The HTTP client that created this call.
    • originalRequest

      public final Request originalRequest
      The original, unmodified request that initiated this call.
    • forWebSocket

      public final boolean forWebSocket
      True if this call is for a WebSocket connection.
    • transmitter

      public Transmitter transmitter
      The transmitter for this call, which manages the connection and exchange.
    • executed

      public boolean executed
      True if this call has been executed.
  • Method Details

    • request

      public Request request()
      Returns the original request that initiated this call.
      Specified by:
      request in interface NewCall
      Returns:
      The original request.
    • execute

      public Response execute() throws IOException
      Executes the request synchronously.
      Specified by:
      execute in interface NewCall
      Returns:
      The response from the server.
      Throws:
      IOException - if the request fails to execute.
      IllegalStateException - if the call has already been executed.
    • enqueue

      public void enqueue(Callback responseCallback)
      Executes the request asynchronously.
      Specified by:
      enqueue in interface NewCall
      Parameters:
      responseCallback - The callback to be invoked with the response or failure.
      Throws:
      IllegalStateException - if the call has already been executed.
    • cancel

      public void cancel()
      Cancels the call.
      Specified by:
      cancel in interface NewCall
    • timeout

      public org.miaixz.bus.core.io.timout.Timeout timeout()
      Returns the timeout configuration for this call.
      Specified by:
      timeout in interface NewCall
      Returns:
      The timeout configuration.
    • timeoutEarlyExit

      public void timeoutEarlyExit()
      Marks this call for an early exit due to a timeout.
    • isExecuted

      public boolean isExecuted()
      Returns whether this call has been executed.
      Specified by:
      isExecuted in interface NewCall
      Returns:
      true if this call has been executed.
    • isCanceled

      public boolean isCanceled()
      Returns whether this call has been canceled.
      Specified by:
      isCanceled in interface NewCall
      Returns:
      true if this call has been canceled.
    • clone

      public RealCall clone()
      Creates a new, identical call to this one.
      Specified by:
      clone in interface NewCall
      Overrides:
      clone in class Object
      Returns:
      A new RealCall instance.
    • toLoggableString

      public String toLoggableString()
      Returns a loggable string representation of this call.
      Returns:
      A string describing the call, without the full URL.
    • redactedUrl

      public String redactedUrl()
      Returns the URL with sensitive information redacted.
      Returns:
      The redacted URL.
    • getResponseWithInterceptorChain

      public Response getResponseWithInterceptorChain() throws IOException
      Gets the response by processing the request through the interceptor chain.
      Returns:
      The response.
      Throws:
      IOException - if an I/O error occurs.