java.lang.Object
org.miaixz.bus.http.RealCall
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionfinal classAn asynchronous call that can be executed on a background thread.Nested classes/interfaces inherited from interface org.miaixz.bus.http.NewCall
NewCall.Factory -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal HttpdThe HTTP client that created this call.booleanTrue if this call has been executed.final booleanTrue if this call is for a WebSocket connection.final RequestThe original, unmodified request that initiated this call.The transmitter for this call, which manages the connection and exchange. -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()Cancels the call.clone()Creates a new, identical call to this one.voidExecutes the request asynchronously.execute()Executes the request synchronously.Gets the response by processing the request through the interceptor chain.booleanReturns whether this call has been canceled.booleanReturns whether this call has been executed.Returns the URL with sensitive information redacted.request()Returns the original request that initiated this call.org.miaixz.bus.core.io.timout.Timeouttimeout()Returns the timeout configuration for this call.voidMarks this call for an early exit due to a timeout.Returns a loggable string representation of this call.
-
Field Details
-
client
The HTTP client that created this call. -
originalRequest
The original, unmodified request that initiated this call. -
forWebSocket
public final boolean forWebSocketTrue if this call is for a WebSocket connection. -
transmitter
The transmitter for this call, which manages the connection and exchange. -
executed
public boolean executedTrue if this call has been executed.
-
-
Method Details
-
request
Returns the original request that initiated this call. -
execute
Executes the request synchronously.- Specified by:
executein interfaceNewCall- Returns:
- The response from the server.
- Throws:
IOException- if the request fails to execute.IllegalStateException- if the call has already been executed.
-
enqueue
Executes the request asynchronously.- Specified by:
enqueuein interfaceNewCall- 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. -
timeout
public org.miaixz.bus.core.io.timout.Timeout timeout()Returns the timeout configuration for this call. -
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:
isExecutedin interfaceNewCall- Returns:
trueif this call has been executed.
-
isCanceled
public boolean isCanceled()Returns whether this call has been canceled.- Specified by:
isCanceledin interfaceNewCall- Returns:
trueif this call has been canceled.
-
clone
Creates a new, identical call to this one. -
toLoggableString
Returns a loggable string representation of this call.- Returns:
- A string describing the call, without the full URL.
-
redactedUrl
Returns the URL with sensitive information redacted.- Returns:
- The redacted URL.
-
getResponseWithInterceptorChain
Gets the response by processing the request through the interceptor chain.- Returns:
- The response.
- Throws:
IOException- if an I/O error occurs.
-