Module bus.http

Class RequestCall

java.lang.Object
org.miaixz.bus.http.plugin.httpz.RequestCall

public class RequestCall extends Object
Represents an executable HTTP request. This class is responsible for building the final Request object from an HttpRequest and executing it either synchronously or asynchronously.
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • RequestCall

      public RequestCall(HttpRequest request, Httpd httpd)
      Constructs a new RequestCall.
      Parameters:
      request - The abstract HttpRequest configuration.
      httpd - The Httpd client instance.
  • Method Details

    • buildCall

      public NewCall buildCall(Callback callback)
      Builds the underlying NewCall from the HttpRequest configuration.
      Parameters:
      callback - The callback to be used for the request.
      Returns:
      The prepared NewCall.
    • execute

      public Response execute() throws Exception
      Executes the HTTP request synchronously.
      Returns:
      The HTTP Response.
      Throws:
      Exception - if an error occurs during execution.
    • executeAsync

      public void executeAsync(Callback callback)
      Executes the HTTP request asynchronously.
      Parameters:
      callback - The callback to handle the response or failure.
    • getNewCall

      public NewCall getNewCall()
      Returns:
      The underlying Httpd NewCall instance.
    • getRequest

      public Request getRequest()
      Returns:
      The final, built Httpd Request object.
    • getHttpRequest

      public HttpRequest getHttpRequest()
      Returns:
      The abstract HttpRequest configuration.
    • cancel

      public void cancel()
      Cancels the request if it is in flight.