Package io.undertow.server
Class AbstractServerConnection
java.lang.Object
io.undertow.util.AbstractAttachable
io.undertow.server.ServerConnection
io.undertow.server.AbstractServerConnection
- All Implemented Interfaces:
Attachable
,Closeable
,AutoCloseable
,Channel
,InterruptibleChannel
,org.xnio.channels.BoundChannel
,org.xnio.channels.CloseableChannel
,org.xnio.channels.Configurable
,org.xnio.channels.ConnectedChannel
- Direct Known Subclasses:
AjpServerConnection
,HttpServerConnection
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class io.undertow.server.ServerConnection
ServerConnection.CloseListener
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ByteBufferPool
protected final org.xnio.StreamConnection
protected final List<ServerConnection.CloseListener>
protected final io.undertow.server.AbstractServerConnection.CloseSetter
protected HttpServerExchange
protected PooledByteBuffer
Any extra bytes that were read from the channel.protected final org.xnio.conduits.StreamSinkConduit
protected final org.xnio.conduits.StreamSourceConduit
protected final HttpHandler
protected final org.xnio.OptionMap
Fields inherited from interface org.xnio.channels.Configurable
EMPTY
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractServerConnection
(org.xnio.StreamConnection channel, ByteBufferPool bufferPool, HttpHandler rootHandler, org.xnio.OptionMap undertowOptions, int bufferSize) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a close listener, than will be invoked with the connection is closedvoid
Resets the channel to its original state, effectively disabling all current conduit wrappers.void
close()
org.xnio.Pool<ByteBuffer>
int
Get the buffer pool for this connection.org.xnio.StreamConnection
Get the underlying channel.org.xnio.ChannelListener.Setter<ServerConnection>
org.xnio.XnioIoThread
<A extends SocketAddress>
AgetLocalAddress
(Class<A> type) <T> T
getOption
(org.xnio.Option<T> option) org.xnio.conduits.StreamSinkConduit
org.xnio.conduits.StreamSourceConduit
Returns the actual address of the remote connection.<A extends SocketAddress>
AgetPeerAddress
(Class<A> type) Returns the actual address of the remote connection.Get the root HTTP handler for this connection.protected org.xnio.conduits.ConduitStreamSinkChannel
protected org.xnio.conduits.ConduitStreamSourceChannel
org.xnio.OptionMap
org.xnio.XnioWorker
boolean
isOpen()
protected void
maxEntitySizeUpdated
(HttpServerExchange exchange) Callback that is invoked if the max entity size is updated.Resets the channel to its original state, effectively disabling all current conduit wrappers.void
Restores the channel conduits to a previous state.void
setExtraBytes
(PooledByteBuffer extraBytes) <T> T
setOption
(org.xnio.Option<T> option, T value) protected void
setUpgradeListener
(HttpUpgradeListener upgradeListener) protected static org.xnio.conduits.StreamSinkConduit
protected static org.xnio.conduits.StreamSourceConduit
boolean
supportsOption
(org.xnio.Option<?> option) Methods inherited from class io.undertow.server.ServerConnection
exchangeComplete, getSinkConduit, getSslSession, getSslSessionInfo, getTransportProtocol, isConnectSupported, isContinueResponseSupported, isPushSupported, isRequestTrailerFieldsSupported, isUpgradeSupported, pushResource, pushResource, sendOutOfBandResponse, setConnectListener, setSslSessionInfo, terminateRequestChannel, upgradeChannel
Methods inherited from class io.undertow.util.AbstractAttachable
addToAttachmentList, createAttachmentMap, getAttachment, getAttachmentList, putAttachment, removeAttachment
-
Field Details
-
channel
protected final org.xnio.StreamConnection channel -
closeSetter
protected final io.undertow.server.AbstractServerConnection.CloseSetter closeSetter -
bufferPool
-
rootHandler
-
undertowOptions
protected final org.xnio.OptionMap undertowOptions -
originalSourceConduit
protected final org.xnio.conduits.StreamSourceConduit originalSourceConduit -
originalSinkConduit
protected final org.xnio.conduits.StreamSinkConduit originalSinkConduit -
closeListeners
-
current
-
extraBytes
Any extra bytes that were read from the channel. This could be data for this requests, or the next response.
-
-
Constructor Details
-
AbstractServerConnection
public AbstractServerConnection(org.xnio.StreamConnection channel, ByteBufferPool bufferPool, HttpHandler rootHandler, org.xnio.OptionMap undertowOptions, int bufferSize)
-
-
Method Details
-
getBufferPool
- Specified by:
getBufferPool
in classServerConnection
- Returns:
- The connections buffer pool
-
getRootHandler
Get the root HTTP handler for this connection.- Returns:
- the root HTTP handler for this connection
-
getByteBufferPool
Get the buffer pool for this connection.- Specified by:
getByteBufferPool
in classServerConnection
- Returns:
- the buffer pool for this connection
-
getChannel
public org.xnio.StreamConnection getChannel()Get the underlying channel.- Returns:
- the underlying channel
-
getCloseSetter
-
getWorker
public org.xnio.XnioWorker getWorker()- Specified by:
getWorker
in interfaceorg.xnio.channels.CloseableChannel
- Specified by:
getWorker
in classServerConnection
- Returns:
- The connections worker
-
getIoThread
public org.xnio.XnioIoThread getIoThread()- Specified by:
getIoThread
in interfaceorg.xnio.channels.CloseableChannel
- Specified by:
getIoThread
in classServerConnection
- Returns:
- The IO thread associated with the connection
-
isOpen
public boolean isOpen()- Specified by:
isOpen
in interfaceChannel
- Specified by:
isOpen
in classServerConnection
- Returns:
- true if the connection is open
-
supportsOption
public boolean supportsOption(org.xnio.Option<?> option) - Specified by:
supportsOption
in interfaceorg.xnio.channels.Configurable
- Specified by:
supportsOption
in classServerConnection
-
getOption
- Specified by:
getOption
in interfaceorg.xnio.channels.Configurable
- Specified by:
getOption
in classServerConnection
- Throws:
IOException
-
setOption
public <T> T setOption(org.xnio.Option<T> option, T value) throws IllegalArgumentException, IOException - Specified by:
setOption
in interfaceorg.xnio.channels.Configurable
- Specified by:
setOption
in classServerConnection
- Throws:
IllegalArgumentException
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceChannel
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceorg.xnio.channels.CloseableChannel
- Specified by:
close
in interfaceInterruptibleChannel
- Specified by:
close
in classServerConnection
- Throws:
IOException
-
getPeerAddress
Description copied from class:ServerConnection
Returns the actual address of the remote connection. This will not take things like X-Forwarded-for into account.- Specified by:
getPeerAddress
in interfaceorg.xnio.channels.ConnectedChannel
- Specified by:
getPeerAddress
in classServerConnection
- Returns:
- The address of the remote peer
-
getPeerAddress
Description copied from class:ServerConnection
Returns the actual address of the remote connection. This will not take things like X-Forwarded-for into account.- Specified by:
getPeerAddress
in interfaceorg.xnio.channels.ConnectedChannel
- Specified by:
getPeerAddress
in classServerConnection
- Type Parameters:
A
- The address type- Parameters:
type
- The type of address to return- Returns:
- The remote endpoint address
-
getLocalAddress
- Specified by:
getLocalAddress
in interfaceorg.xnio.channels.BoundChannel
- Specified by:
getLocalAddress
in classServerConnection
-
getLocalAddress
- Specified by:
getLocalAddress
in interfaceorg.xnio.channels.BoundChannel
- Specified by:
getLocalAddress
in classServerConnection
-
getUndertowOptions
public org.xnio.OptionMap getUndertowOptions()- Specified by:
getUndertowOptions
in classServerConnection
-
getBufferSize
public int getBufferSize()- Specified by:
getBufferSize
in classServerConnection
- Returns:
- The size of the buffers allocated by the buffer pool
-
getExtraBytes
-
setExtraBytes
-
getOriginalSourceConduit
public org.xnio.conduits.StreamSourceConduit getOriginalSourceConduit()- Returns:
- The original source conduit
-
getOriginalSinkConduit
public org.xnio.conduits.StreamSinkConduit getOriginalSinkConduit()- Returns:
- The original underlying sink conduit
-
resetChannel
Resets the channel to its original state, effectively disabling all current conduit wrappers. The current state is encapsulated inside aAbstractServerConnection.ConduitState
object that can be used the restore the channel.- Returns:
- An opaque representation of the previous channel state
-
clearChannel
public void clearChannel()Resets the channel to its original state, effectively disabling all current conduit wrappers. The current state is lost. -
restoreChannel
Restores the channel conduits to a previous state.- Parameters:
state
- The original state- See Also:
-
sink
protected static org.xnio.conduits.StreamSinkConduit sink(AbstractServerConnection.ConduitState state) -
source
protected static org.xnio.conduits.StreamSourceConduit source(AbstractServerConnection.ConduitState state) -
addCloseListener
Description copied from class:ServerConnection
Adds a close listener, than will be invoked with the connection is closed- Specified by:
addCloseListener
in classServerConnection
- Parameters:
listener
- The close listener
-
getSinkChannel
protected org.xnio.conduits.ConduitStreamSinkChannel getSinkChannel()- Specified by:
getSinkChannel
in classServerConnection
-
getSourceChannel
protected org.xnio.conduits.ConduitStreamSourceChannel getSourceChannel()- Specified by:
getSourceChannel
in classServerConnection
-
setUpgradeListener
- Specified by:
setUpgradeListener
in classServerConnection
-
maxEntitySizeUpdated
Description copied from class:ServerConnection
Callback that is invoked if the max entity size is updated.- Specified by:
maxEntitySizeUpdated
in classServerConnection
- Parameters:
exchange
- The current exchange
-