Package io.undertow.websockets.spi
Interface WebSocketHttpExchange
-
- All Superinterfaces:
java.lang.AutoCloseable,java.io.Closeable
- All Known Implementing Classes:
AsyncWebSocketHttpServerExchange,BlockingWebSocketHttpServerExchange
public interface WebSocketHttpExchange extends java.io.CloseableAn 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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclose()Forcibly close the exchange.voidendExchange()End the exchange normally.<T> TgetAttachment(AttachmentKey<T> key)ByteBufferPoolgetBufferPool()org.xnio.OptionMapgetOptions()java.util.Set<WebSocketChannel>getPeerConnections()java.lang.StringgetQueryString()java.lang.StringgetRequestHeader(java.lang.String headerName)gets the first request header with the specified namejava.util.Map<java.lang.String,java.util.List<java.lang.String>>getRequestHeaders()java.util.Map<java.lang.String,java.util.List<java.lang.String>>getRequestParameters()java.lang.StringgetRequestScheme()Get the request scheme, usually http or httpsjava.lang.StringgetRequestURI()java.lang.StringgetResponseHeader(java.lang.String headerName)get a response headerjava.util.Map<java.lang.String,java.util.List<java.lang.String>>getResponseHeaders()java.lang.ObjectgetSession()Gets the session, if anyjava.security.PrincipalgetUserPrincipal()booleanisUserInRole(java.lang.String role)<T> voidputAttachment(AttachmentKey<T> key, T value)org.xnio.IoFuture<byte[]>readRequestData()Gets the body of the request.org.xnio.IoFuture<java.lang.Void>sendData(java.nio.ByteBuffer data)Send some datavoidsetResponseHeader(java.lang.String headerName, java.lang.String headerValue)Set a response headervoidsetResponseHeaders(java.util.Map<java.lang.String,java.util.List<java.lang.String>> headers)Sets the response headersvoidupgradeChannel(HttpUpgradeListener upgradeCallback)Upgrade the underlying channel
-
-
-
Method Detail
-
putAttachment
<T> void putAttachment(AttachmentKey<T> key, T value)
-
getAttachment
<T> T getAttachment(AttachmentKey<T> key)
-
getRequestHeader
java.lang.String getRequestHeader(java.lang.String headerName)
gets the first request header with the specified name- Parameters:
headerName- The header name- Returns:
- The header value, or null
-
getRequestHeaders
java.util.Map<java.lang.String,java.util.List<java.lang.String>> getRequestHeaders()
- Returns:
- An unmodifiable map of request headers
-
getResponseHeader
java.lang.String getResponseHeader(java.lang.String headerName)
get a response header- Parameters:
headerName- The header name- Returns:
- The header value, or null
-
getResponseHeaders
java.util.Map<java.lang.String,java.util.List<java.lang.String>> getResponseHeaders()
- Returns:
- An unmodifiable map of response headers
-
setResponseHeaders
void setResponseHeaders(java.util.Map<java.lang.String,java.util.List<java.lang.String>> headers)
Sets the response headers
-
setResponseHeader
void setResponseHeader(java.lang.String headerName, java.lang.String headerValue)Set a response header- Parameters:
headerName- The header nameheaderValue- The header value
-
upgradeChannel
void upgradeChannel(HttpUpgradeListener upgradeCallback)
Upgrade the underlying channel- Parameters:
upgradeCallback-
-
sendData
org.xnio.IoFuture<java.lang.Void> sendData(java.nio.ByteBuffer data)
Send some data- Parameters:
data- The data
-
readRequestData
org.xnio.IoFuture<byte[]> readRequestData()
Gets the body of the request.
-
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 interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
getRequestScheme
java.lang.String getRequestScheme()
Get the request scheme, usually http or https- Returns:
- The request scheme
-
getRequestURI
java.lang.String getRequestURI()
- Returns:
- The request URI, including the query string
-
getBufferPool
ByteBufferPool getBufferPool()
- Returns:
- The buffer pool
-
getQueryString
java.lang.String getQueryString()
- Returns:
- The query string
-
getSession
java.lang.Object getSession()
Gets the session, if any- Returns:
- The session object, or null
-
getRequestParameters
java.util.Map<java.lang.String,java.util.List<java.lang.String>> getRequestParameters()
-
getUserPrincipal
java.security.Principal getUserPrincipal()
-
isUserInRole
boolean isUserInRole(java.lang.String role)
-
getPeerConnections
java.util.Set<WebSocketChannel> getPeerConnections()
-
getOptions
org.xnio.OptionMap getOptions()
-
-