Interface Exchange<A extends ExchangeContext>

Type Parameters:
A - the type of the exchange context
All Superinterfaces:
BaseExchange<A,Request,Response>
All Known Subinterfaces:
ErrorExchange<A>

public interface Exchange<A extends ExchangeContext> extends BaseExchange<A,Request,Response>

Represents an HTTP server exchange (request/response) between a client and a server.

An HTTP server exchange is created when a Request is received from a client by the HTTP server which then processes the exchange in the ServerController.

When creating the exchange, the HTTP server also invokes ServerController.createContext() to create an exchange context and attach it to the new server exchange.

Since:
1.0
Author:
Jeremy Kuhn
See Also:
  • Method Details

    • webSocket

      Optional<? extends WebSocket<A,? extends WebSocketExchange<A>>> webSocket(String... subProtocols)

      Upgrades the exchange to a WebSocket exchange.

      If the exchange cannot upgrade to the WebSocket protocol, an empty optional shall be returned. For instance, if the state of the exchange prevents the upgrade (e.g. error exchange) or if the underlying HTTP protocol does not support the upgrade operation. Currently only HTTP/1.1 can upgrade to the WebSocket protocol.

      Parameters:
      subProtocols - a list of supported subprotocols negotiated during the handshake
      Returns:
      an optional returning the WebSocket or an empty optional if the upgrade is not possible
    • finalizer

      void finalizer(reactor.core.publisher.Mono<Void> finalizer)

      Specifies a finalizer which is subscribed once the exchange is fully processed.

      An exchange is considered fully processed when the last chunk of the response has been fully sent to the client or following a terminal error.

      Note that using a finalizer actually impacts HTTP pipelining since the server has to wait for the response to be fully sent and for the finalizer to complete before processing subsequent requests.

      When invoked multiple time this method chains the finalizer one after the other.

      Parameters:
      finalizer - a finalizer