Interface Exchange<A extends ExchangeContext>
- Type Parameters:
A- the type of the exchange context
- All Known Subinterfaces:
ErrorExchange<A>
Represents an HTTP server exchange (request/response) between a client and a server.
The HTTP server attaches an exchange context provided by ServerController.createContext() when an exchange is created.
An HTTP server exchange is processed in the ServerController of the HTTP server.
- Since:
- 1.0
- Author:
- Jeremy Kuhn
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptioncontext()Returns the context attached to the exchange.Specifies a finalizer to the exchange which completes once the exchange is fully processed.request()Returns the request part of the exchange.response()Returns the response part of the exchange.Optional<? extends WebSocket<A,? extends WebSocketExchange<A>>> Upgrades the exchange to a WebSocket exchange.
-
Method Details
-
request
Request request()Returns the request part of the exchange.
- Returns:
- the request part
-
response
Response response()Returns the response part of the exchange.
- Returns:
- the response part
-
context
A context()Returns the context attached to the exchange.
- Returns:
- the exchange context or null
-
webSocket
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, an empty optional shall be returned. 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
Specifies a finalizer to the exchange which completes once the exchange is fully processed.
A exchange is considered fully processed when the last chunk of the response has been fully sent to the client or following an error.
Note that using a finalizer actually impacts HTTP pipelining since the server wait for the response to be fully sent to the client before processing following requests.
- Parameters:
finalizer- a finalizer- Returns:
- the exchange
-