Top Description Methods
io.undertow.websockets.spi

public Interface WebSocketHttpExchange

extends Closeable
Known Direct Implementers
io.undertow.websockets.spi.AsyncWebSocketHttpServerExchange
Imports
io.undertow.server.HttpUpgradeListener, io.undertow.util.AttachmentKey, io.undertow.websockets.core.WebSocketChannel, org.xnio.IoFuture, .OptionMap, io.undertow.connector.ByteBufferPool, java.io.Closeable, java.nio.ByteBuffer, java.security.Principal, java.util.List, .Map, .Set

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 TypeMethod and Description
public void
close()

Redeclares java.io.Closeable.close.

Forcibly close the exchange.

public void
endExchange()

End the exchange normally.

public <T> T
public ByteBufferPool

Returns:

The buffer pool
getBufferPool
()

public OptionMap
public Set<WebSocketChannel>
public String

Returns:

The query string
getQueryString
()

public String

Returns:

The header value, or null
getRequestHeader
(final String
The header name
headerName
)

gets the first request header with the specified name

public Map<String, List<String>>

Returns:

An unmodifiable map of request headers
getRequestHeaders
()

public Map<String, List<String>>
public String

Returns:

The request scheme
getRequestScheme
()

Get the request scheme, usually http or https

public String

Returns:

The request URI, including the query string
getRequestURI
()

public String

Returns:

The header value, or null
getResponseHeader
(final String
The header name
headerName
)

get a response header

public Map<String, List<String>>

Returns:

An unmodifiable map of response headers
getResponseHeaders
()

public Object

Returns:

The session object, or null
getSession
()

Gets the session, if any

public Principal
public boolean
public <T> void
putAttachment(final AttachmentKey<T> key, T value)

public IoFuture<byte[]>
readRequestData()

Gets the body of the request.

public IoFuture<Void>
sendData(final ByteBuffer
The data
data
)

Send some data

public void
setResponseHeader(final String
The header name
headerName
,
final String
The header value
headerValue
)

Set a response header

public void
setResponseHeaders(final Map<String, List<String>> headers)

Sets the response headers

public void
upgradeChannel(final HttpUpgradeListener upgradeCallback)

Upgrade the underlying channel

Method Detail

closeback to summary
public void close()

Redeclares java.io.Closeable.close.

Forcibly close the exchange.

endExchangeback to summary
public 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

getAttachmentback to summary
public <T> T getAttachment(final AttachmentKey<T> key)
getBufferPoolback to summary
public ByteBufferPool getBufferPool()
Returns:ByteBufferPool

The buffer pool

getOptionsback to summary
public OptionMap getOptions()
getPeerConnectionsback to summary
public Set<WebSocketChannel> getPeerConnections()
getQueryStringback to summary
public String getQueryString()
Returns:String

The query string

getRequestHeaderback to summary
public String getRequestHeader(final String headerName)

gets the first request header with the specified name

Parameters
headerName:String

The header name

Returns:String

The header value, or null

getRequestHeadersback to summary
public Map<String, List<String>> getRequestHeaders()
Returns:Map<String, List<String>>

An unmodifiable map of request headers

getRequestParametersback to summary
public Map<String, List<String>> getRequestParameters()
getRequestSchemeback to summary
public String getRequestScheme()

Get the request scheme, usually http or https

Returns:String

The request scheme

getRequestURIback to summary
public String getRequestURI()
Returns:String

The request URI, including the query string

getResponseHeaderback to summary
public String getResponseHeader(final String headerName)

get a response header

Parameters
headerName:String

The header name

Returns:String

The header value, or null

getResponseHeadersback to summary
public Map<String, List<String>> getResponseHeaders()
Returns:Map<String, List<String>>

An unmodifiable map of response headers

getSessionback to summary
public Object getSession()

Gets the session, if any

Returns:Object

The session object, or null

getUserPrincipalback to summary
public Principal getUserPrincipal()
isUserInRoleback to summary
public boolean isUserInRole(String role)
putAttachmentback to summary
public <T> void putAttachment(final AttachmentKey<T> key, T value)
readRequestDataback to summary
public IoFuture<byte[]> readRequestData()

Gets the body of the request.

sendDataback to summary
public IoFuture<Void> sendData(final ByteBuffer data)

Send some data

Parameters
data:ByteBuffer

The data

setResponseHeaderback to summary
public void setResponseHeader(final String headerName, final String headerValue)

Set a response header

Parameters
headerName:String

The header name

headerValue:String

The header value

setResponseHeadersback to summary
public void setResponseHeaders(final Map<String, List<String>> headers)

Sets the response headers

upgradeChannelback to summary
public void upgradeChannel(final HttpUpgradeListener upgradeCallback)

Upgrade the underlying channel