Module bus.http

Class Transmitter

java.lang.Object
org.miaixz.bus.http.accord.Transmitter

public class Transmitter extends Object
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 Details

    • connection

      public RealConnection connection
      The connection that carries the request and response. Guarded by connectionPool.
  • Constructor Details

    • Transmitter

      public Transmitter(Httpd client, NewCall call)
  • 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

      public void prepareToConnect(Request request)
      Prepare to create a stream to carry request. 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

      public IOException noMoreExchanges(IOException e)
      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:
      true if a retry is possible.
    • hasExchange

      public boolean hasExchange()
      Returns true if this transmitter has an active exchange.
      Returns:
      true if 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:
      true if this transmitter has been canceled.