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>, ErrorWebExchange<A>, WebExchange<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