Package io.undertow.websockets.handshake
Interface WebSocketHttpExchange
- All Superinterfaces:
AutoCloseable,Closeable
An abstraction for a Http exchange. Undertow uses 3 different types of exchanges:
- async - blocking - servlet
This class provides a way to operate on the underling exchange while providing the correct semantics regardless of the underlying exchange type.
The main use case for this is web sockets. Web sockets should be able to perform a handshake regardless of the nature of the underlying request, while still respecting servlet filters, security etc.
- Author:
- Stuart Douglas
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Forcibly close the exchange.voidEnd the exchange normally.<T> TgetAttachment(String key) getRequestHeader(CharSequence headerName) gets the first request header with the specified nameGet the request scheme, usually http or httpsgetResponseHeader(CharSequence headerName) get a response headerGets the session, if anybooleanisUserInRole(String role) <T> voidputAttachment(String key, T value) voidsetResponseHeader(CharSequence headerName, String headerValue) Set a response headervoidsetResponseHeaders(Map<String, List<String>> headers) Sets the response headersvoidupgradeChannel(Consumer<Object> listener) Upgrade the underlying channel
-
Method Details
-
putAttachment
-
getAttachment
-
getRequestHeader
gets the first request header with the specified name- Parameters:
headerName- The header name- Returns:
- The header value, or null
-
getRequestHeaders
- Returns:
- An unmodifiable map of request headers
-
getResponseHeader
get a response header- Parameters:
headerName- The header name- Returns:
- The header value, or null
-
getResponseHeaders
- Returns:
- An unmodifiable map of response headers
-
setResponseHeaders
Sets the response headers -
setResponseHeader
Set a response header- Parameters:
headerName- The header nameheaderValue- The header value
-
upgradeChannel
Upgrade the underlying channel- Parameters:
listener-
-
endExchange
void endExchange()End the exchange normally. If this is a blocking exchange this may be a noop, and the exchange will actually end when the call stack returns -
close
void close()Forcibly close the exchange.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
getRequestScheme
String getRequestScheme()Get the request scheme, usually http or https- Returns:
- The request scheme
-
getRequestURI
String getRequestURI()- Returns:
- The request URI, including the query string
-
getQueryString
String getQueryString()- Returns:
- The query string
-
getSession
Object getSession()Gets the session, if any- Returns:
- The session object, or null
-
getRequestParameters
-
getUserPrincipal
Principal getUserPrincipal() -
isUserInRole
-
getExecutor
Executor getExecutor()
-