java.lang.Object
org.miaixz.bus.http.accord.Transmitter
Bridges the application layer with the network layer, managing the lifecycle of a single call. This class exposes
connections, requests, responses, and streams.
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe connection that carries the request and response. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidRecords the stack trace at the point the call is started.voidcancel()Immediately closes the socket connection if it's currently held.booleancanRetry()Returns true if this transmitter can retry a failed request.voidNotifies this transmitter that the exchange has completed due to an exception.booleanReturns true if this transmitter has an active exchange.booleanReturns true if this transmitter has been canceled.Notifies this transmitter that no more exchanges are expected.voidprepareToConnect(Request request) Prepare to create a stream to carryrequest.org.miaixz.bus.core.io.timout.Timeouttimeout()voidStops applying the timeout before the call is complete.void
-
Field Details
-
connection
The connection that carries the request and response. Guarded by connectionPool.
-
-
Constructor Details
-
Transmitter
-
-
Method Details
-
timeout
public org.miaixz.bus.core.io.timout.Timeout timeout() -
timeoutEnter
public void timeoutEnter() -
timeoutEarlyExit
public void timeoutEarlyExit()Stops applying the timeout before the call is complete. This is used for WebSockets and duplex calls where the timeout only applies to the initial setup. -
callStart
public void callStart()Records the stack trace at the point the call is started. This is used to identify the source of connection leaks. -
prepareToConnect
Prepare to create a stream to carryrequest. This prefers to use an existing connection if one exists.- Parameters:
request- The request to prepare for.
-
exchangeDoneDueToException
public void exchangeDoneDueToException()Notifies this transmitter that the exchange has completed due to an exception. -
noMoreExchanges
Notifies this transmitter that no more exchanges are expected.- Parameters:
e- The exception that occurred, or null if none.- Returns:
- The exception, or null if none.
-
canRetry
public boolean canRetry()Returns true if this transmitter can retry a failed request.- Returns:
trueif a retry is possible.
-
hasExchange
public boolean hasExchange()Returns true if this transmitter has an active exchange.- Returns:
trueif there is an active exchange.
-
cancel
public void cancel()Immediately closes the socket connection if it's currently held. Use this to interrupt an in-flight request from any thread. It's the caller's responsibility to close the request body and response body streams; otherwise resources may be leaked. This method is safe to be called concurrently, but provides limited guarantees. If a transport layer connection has been established (such as a HTTP/2 stream) that is terminated. Otherwise if a socket connection is being established, that is terminated. -
isCanceled
public boolean isCanceled()Returns true if this transmitter has been canceled.- Returns:
trueif this transmitter has been canceled.
-