Top Description Inners Fields Constructors Methods
io.undertow.server

public abstract Class ServerConnection

extends AbstractAttachable
implements ConnectedChannel
Class Inheritance
All Implemented Interfaces
org.xnio.channels.ConnectedChannel, org.xnio.channels.BoundChannel, org.xnio.channels.CloseableChannel, org.xnio.channels.Configurable, java.nio.channels.InterruptibleChannel, java.nio.channels.Channel, java.io.Closeable, java.lang.AutoCloseable
Known Direct Subclasses
io.undertow.server.protocol.http2.Http2ServerConnection, io.undertow.server.AbstractServerConnection
Imports
io.undertow.connector.ByteBufferPool, io.undertow.util.AbstractAttachable, .HeaderMap, .HttpString, org.xnio.Option, .OptionMap, .Pool, .StreamConnection, .XnioIoThread, .XnioWorker, org.xnio.channels.ConnectedChannel, org.xnio.conduits.ConduitStreamSinkChannel, .ConduitStreamSourceChannel, .StreamSinkConduit, java.io.IOException, java.net.SocketAddress, java.nio.ByteBuffer, java.util.concurrent.atomic.AtomicLong, javax.net.ssl.SSLSession

A server connection.
Author
Stuart Douglas

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface

Field Summary

Modifier and TypeField and Description
private static final AtomicLong
private final long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract void
addCloseListener(ServerConnection.CloseListener
The close listener
listener
)

Adds a close listener, than will be invoked with the connection is closed

public abstract void
close()

Redeclares org.xnio.channels.CloseableChannel.close.

Close this channel.

protected abstract void
exchangeComplete(HttpServerExchange exchange)

Invoked when the exchange is complete.

public abstract Pool<ByteBuffer>

Returns:

The connections buffer pool
getBufferPool
()
Deprecated

public abstract int
public abstract ByteBufferPool

Returns:

The connections buffer pool
getByteBufferPool
()

public final long
public abstract XnioIoThread

Returns:

The IO thread associated with the connection
getIoThread
()

Redeclares org.xnio.channels.CloseableChannel.getIoThread.

Get the I/O thread associated with this channel.

public abstract SocketAddress
getLocalAddress()

Redeclares org.xnio.channels.BoundChannel.getLocalAddress.

Get the local address that this channel is bound to.

public abstract <A extends SocketAddress> A
getLocalAddress(Class<A>
the address type class
type
)

Redeclares org.xnio.channels.BoundChannel.getLocalAddress.

Get the local address of a given type, or null if the address is not of that type.

public abstract <T> T
getOption(Option<T>
the option to get
option
)

Redeclares org.xnio.channels.Configurable.getOption.

Get the value of a channel option.

public abstract SocketAddress

Returns:

The address of the remote peer
getPeerAddress
()

Redeclares org.xnio.channels.ConnectedChannel.getPeerAddress.

Returns the actual address of the remote connection.

public abstract <
The address type
A extends SocketAddress
>
A

Returns:

The remote endpoint address
getPeerAddress
(Class<A>
The type of address to return
type
)

Redeclares org.xnio.channels.ConnectedChannel.getPeerAddress.

Returns the actual address of the remote connection.

public String
protected abstract ConduitStreamSinkChannel
protected abstract StreamSinkConduit

Returns:

The source conduit
getSinkConduit
(HttpServerExchange exchange, final StreamSinkConduit conduit)

Gets the sink conduit that should be used for this request.

protected abstract ConduitStreamSourceChannel
public SSLSession

Returns:

The SSLSession of the connection
getSslSession
()

Gets the SSLSession of the underlying connection, or null if SSL is not in use.

public abstract SSLSessionInfo

Returns:

SSL information about the connection
getSslSessionInfo
()

Gets SSL information about the connection.

public abstract String

Returns:

the transport protocol
getTransportProtocol
()

Returns a string representation describing the protocol used to transmit messages on this connection.

public abstract OptionMap
public abstract XnioWorker

Returns:

The connections worker
getWorker
()

Redeclares org.xnio.channels.CloseableChannel.getWorker.

Get the worker for this channel.

protected abstract boolean

Returns:

true if this connection supports the HTTP CONNECT verb
isConnectSupported
()

public abstract boolean

Returns:

true if this connection supports sending a 100-continue response
isContinueResponseSupported
()

public abstract boolean

Returns:

true if the connection is open
isOpen
()

Redeclares java.nio.channels.Channel.isOpen.

Tells whether or not this channel is open.

public boolean
public abstract boolean
protected abstract boolean

Returns:

true if this connection supports HTTP upgrade
isUpgradeSupported
()

protected abstract void
maxEntitySizeUpdated(HttpServerExchange
The current exchange
exchange
)

Callback that is invoked if the max entity size is updated.

public boolean

Returns:

true if the server attempted the push, false otherwise
pushResource
(final String
The path of the resource
path
,
final HttpString
The request method
method
,
final HeaderMap
The request headers
requestHeaders
)

Attempts to push a resource if this connection supports server push.

public boolean

Returns:

true if the server attempted the push, false otherwise
pushResource
(final String
The path of the resource
path
,
final HttpString
The request method
method
,
final HeaderMap
The request headers
requestHeaders
,
HttpHandler handler)

Attempts to push a resource if this connection supports server push.

public abstract HttpServerExchange

Returns:

The out of band exchange.
sendOutOfBandResponse
(HttpServerExchange
The current exchange
exchange
)

Sends an out of band response, such as a HTTP 100-continue response.

protected abstract void
public abstract <T> T
setOption(Option<T>
the option to set
option
,
T
the value of the option to set
value
)

Redeclares org.xnio.channels.Configurable.setOption.

Set an option for this channel.

public abstract void
setSslSessionInfo(SSLSessionInfo
The ssl session information
sessionInfo
)

Sets the current SSL information.

protected abstract void
public abstract boolean
supportsOption(Option<?>
the option
option
)

Redeclares org.xnio.channels.Configurable.supportsOption.

Determine whether an option is supported on this channel.

public abstract void
terminateRequestChannel(HttpServerExchange
The current exchange.
exchange
)

Invoked when the exchange is complete, and there is still data in the request channel.

protected abstract StreamConnection

Returns:

The StreamConnection that should be passed to the upgrade handler
upgradeChannel
()

Upgrade the connection, if allowed

Inherited from io.undertow.util.AbstractAttachable:
addToAttachmentListcreateAttachmentMapgetAttachmentgetAttachmentListputAttachmentremoveAttachment

Field Detail

CONNECTION_ID_GENERATORback to summary
private static final AtomicLong CONNECTION_ID_GENERATOR
idback to summary
private final long id

Constructor Detail

ServerConnectionback to summary
public ServerConnection()

Method Detail

addCloseListenerback to summary
public abstract void addCloseListener(ServerConnection.CloseListener listener)

Adds a close listener, than will be invoked with the connection is closed

Parameters
listener:ServerConnection.CloseListener

The close listener

closeback to summary
public abstract void close() throws IOException

Redeclares org.xnio.channels.CloseableChannel.close.

Doc from org.xnio.channels.CloseableChannel.close.

Close this channel. When a channel is closed, its close listener is invoked. Invoking this method more than once has no additional effect.

Exceptions
IOException:
if the close failed
exchangeCompleteback to summary
protected abstract void exchangeComplete(HttpServerExchange exchange)

Invoked when the exchange is complete.

getBufferPoolback to summary
public abstract Pool<ByteBuffer> getBufferPool()

Deprecated

Returns:Pool<ByteBuffer>

The connections buffer pool

Annotations
@Deprecated
getBufferSizeback to summary
public abstract int getBufferSize()
getByteBufferPoolback to summary
public abstract ByteBufferPool getByteBufferPool()
Returns:ByteBufferPool

The connections buffer pool

getIdback to summary
public final long getId()
getIoThreadback to summary
public abstract XnioIoThread getIoThread()

Redeclares org.xnio.channels.CloseableChannel.getIoThread.

Doc from org.xnio.channels.CloseableChannel.getIoThread.

Get the I/O thread associated with this channel.

Returns:XnioIoThread

The IO thread associated with the connection

Annotations
@Override
getLocalAddressback to summary
public abstract SocketAddress getLocalAddress()

Redeclares org.xnio.channels.BoundChannel.getLocalAddress.

Doc from org.xnio.channels.BoundChannel.getLocalAddress.

Get the local address that this channel is bound to.

Returns:SocketAddress

the local address

getLocalAddressback to summary
public abstract <A extends SocketAddress> A getLocalAddress(Class<A> type)

Redeclares org.xnio.channels.BoundChannel.getLocalAddress.

Doc from org.xnio.channels.BoundChannel.getLocalAddress.

Get the local address of a given type, or null if the address is not of that type.

Parameters
<A>
the address type
type:Class<A>

the address type class

Returns:A

the local address, or null if unknown

getOptionback to summary
public abstract <T> T getOption(Option<T> option) throws IOException

Redeclares org.xnio.channels.Configurable.getOption.

Doc from org.xnio.channels.Configurable.getOption.

Get the value of a channel option.

Parameters
<T>
the type of the option value
option:Option<T>

the option to get

Returns:T

the value of the option, or null if it is not set

Exceptions
IOException:
if an I/O error occurred when reading the option
getPeerAddressback to summary
public abstract SocketAddress getPeerAddress()

Redeclares org.xnio.channels.ConnectedChannel.getPeerAddress.

Returns the actual address of the remote connection. This will not take things like X-Forwarded-for into account.

Returns:SocketAddress

The address of the remote peer

getPeerAddressback to summary
public abstract <A extends SocketAddress> A getPeerAddress(Class<A> type)

Redeclares org.xnio.channels.ConnectedChannel.getPeerAddress.

Returns the actual address of the remote connection. This will not take things like X-Forwarded-for into account.

Parameters
<A>
The address type
type:Class<A>

The type of address to return

Returns:A

The remote endpoint address

getProtocolRequestIdback to summary
public String getProtocolRequestId()
getSinkChannelback to summary
protected abstract ConduitStreamSinkChannel getSinkChannel()
getSinkConduitback to summary
protected abstract StreamSinkConduit getSinkConduit(HttpServerExchange exchange, final StreamSinkConduit conduit)

Gets the sink conduit that should be used for this request. This allows the connection to apply any per-request conduit wrapping that is required, without adding to the response wrappers array. There is no corresponding method for source conduits, as in general conduits can be directly inserted into the connection after the request has been read.

Returns:StreamSinkConduit

The source conduit

getSourceChannelback to summary
protected abstract ConduitStreamSourceChannel getSourceChannel()
getSslSessionback to summary
public SSLSession getSslSession()

Gets the SSLSession of the underlying connection, or null if SSL is not in use. Note that for client cert auth getSslSessionInfo() should be used instead, as it takes into account other information potentially provided by load balancers that terminate SSL

Returns:SSLSession

The SSLSession of the connection

getSslSessionInfoback to summary
public abstract SSLSessionInfo getSslSessionInfo()

Gets SSL information about the connection. This could represent the actual client connection, or could be providing SSL information that was provided by a front end proxy.

Returns:SSLSessionInfo

SSL information about the connection

getTransportProtocolback to summary
public abstract String getTransportProtocol()

Returns a string representation describing the protocol used to transmit messages on this connection.

Returns:String

the transport protocol

getUndertowOptionsback to summary
public abstract OptionMap getUndertowOptions()
getWorkerback to summary
public abstract XnioWorker getWorker()

Redeclares org.xnio.channels.CloseableChannel.getWorker.

Doc from org.xnio.channels.CloseableChannel.getWorker.

Get the worker for this channel.

Returns:XnioWorker

The connections worker

isConnectSupportedback to summary
protected abstract boolean isConnectSupported()
Returns:boolean

true if this connection supports the HTTP CONNECT verb

isContinueResponseSupportedback to summary
public abstract boolean isContinueResponseSupported()
Returns:boolean

true if this connection supports sending a 100-continue response

isOpenback to summary
public abstract boolean isOpen()

Redeclares java.nio.channels.Channel.isOpen.

Doc from java.nio.channels.Channel.isOpen.

Tells whether or not this channel is open.

Returns:boolean

true if the connection is open

isPushSupportedback to summary
public boolean isPushSupported()
isRequestTrailerFieldsSupportedback to summary
public abstract boolean isRequestTrailerFieldsSupported()
isUpgradeSupportedback to summary
protected abstract boolean isUpgradeSupported()
Returns:boolean

true if this connection supports HTTP upgrade

maxEntitySizeUpdatedback to summary
protected abstract void maxEntitySizeUpdated(HttpServerExchange exchange)

Callback that is invoked if the max entity size is updated.

Parameters
exchange:HttpServerExchange

The current exchange

pushResourceback to summary
public boolean pushResource(final String path, final HttpString method, final HeaderMap requestHeaders)

Attempts to push a resource if this connection supports server push. Otherwise the request is ignored. Note that push is always done on a best effort basis, even if this method returns true it is possible that the remote endpoint will reset the stream

Parameters
path:String

The path of the resource

method:HttpString

The request method

requestHeaders:HeaderMap

The request headers

Returns:boolean

true if the server attempted the push, false otherwise

pushResourceback to summary
public boolean pushResource(final String path, final HttpString method, final HeaderMap requestHeaders, HttpHandler handler)

Attempts to push a resource if this connection supports server push. Otherwise the request is ignored. Note that push is always done on a best effort basis, even if this method returns true it is possible that the remote endpoint will reset the stream. The io.undertow.server.HttpHandler passed in will be used to generate the pushed response

Parameters
path:String

The path of the resource

method:HttpString

The request method

requestHeaders:HeaderMap

The request headers

Returns:boolean

true if the server attempted the push, false otherwise

sendOutOfBandResponseback to summary
public abstract HttpServerExchange sendOutOfBandResponse(HttpServerExchange exchange)

Sends an out of band response, such as a HTTP 100-continue response.

Warning

do not attempt to write to the current exchange until the out of band exchange has been fully written. Doing so may have unexpected results.

Todo

this needs more thought.

Parameters
exchange:HttpServerExchange

The current exchange

Returns:HttpServerExchange

The out of band exchange.

setConnectListenerback to summary
protected abstract void setConnectListener(HttpUpgradeListener connectListener)
setOptionback to summary
public abstract <T> T setOption(Option<T> option, T value) throws IllegalArgumentException, IOException

Redeclares org.xnio.channels.Configurable.setOption.

Doc from org.xnio.channels.Configurable.setOption.

Set an option for this channel. Unsupported options are ignored.

Parameters
<T>
the type of the option value
option:Option<T>

the option to set

value:T

the value of the option to set

Returns:T

the previous option value, if any

Exceptions
IllegalArgumentException:
if the value is not acceptable for this option
IOException:
if an I/O error occurred when modifying the option
setSslSessionInfoback to summary
public abstract void setSslSessionInfo(SSLSessionInfo sessionInfo)

Sets the current SSL information. This can be used by handlers to setup SSL information that was provided by a front end proxy. If this is being set of a per request basis then you must ensure that it is either cleared by an exchange completion listener at the end of the request, or is always set for every request. Otherwise it is possible to SSL information to 'leak' between requests.

Parameters
sessionInfo:SSLSessionInfo

The ssl session information

setUpgradeListenerback to summary
protected abstract void setUpgradeListener(HttpUpgradeListener upgradeListener)
supportsOptionback to summary
public abstract boolean supportsOption(Option<?> option)

Redeclares org.xnio.channels.Configurable.supportsOption.

Doc from org.xnio.channels.Configurable.supportsOption.

Determine whether an option is supported on this channel.

Parameters
option:Option<?>

the option

Returns:boolean

true if it is supported

terminateRequestChannelback to summary
public abstract void terminateRequestChannel(HttpServerExchange exchange)

Invoked when the exchange is complete, and there is still data in the request channel. Some implementations (such as SPDY and HTTP2) have more efficient ways to drain the request than simply reading all data (e.g. RST_STREAM). After this method is invoked the stream will be drained normally.

Parameters
exchange:HttpServerExchange

The current exchange.

upgradeChannelback to summary
protected abstract StreamConnection upgradeChannel()

Upgrade the connection, if allowed

Returns:StreamConnection

The StreamConnection that should be passed to the upgrade handler

io.undertow.server back to summary

public Interface ServerConnection.CloseListener

Known Direct Implementers
io.undertow.server.protocol.ParseTimeoutUpdater

Method Summary

Modifier and TypeMethod and Description
public void
closed(final ServerConnection connection)

Method Detail

closedback to summary
public void closed(final ServerConnection connection)