Package io.undertow.server.protocol.http
Class HttpServerConnection
java.lang.Object
io.undertow.util.AbstractAttachable
io.undertow.server.ServerConnection
io.undertow.server.AbstractServerConnection
io.undertow.server.protocol.http.HttpServerConnection
- All Implemented Interfaces:
Attachable
,Closeable
,AutoCloseable
,Channel
,InterruptibleChannel
,org.xnio.channels.BoundChannel
,org.xnio.channels.CloseableChannel
,org.xnio.channels.Configurable
,org.xnio.channels.ConnectedChannel
A server-side HTTP connection.
Note that the lifecycle of the server connection is tied to the underlying TCP connection. Even if the channel is upgraded the connection is not considered closed until the upgraded channel is closed.
- Author:
- David M. Lloyd
-
Nested Class Summary
Nested classes/interfaces inherited from class io.undertow.server.AbstractServerConnection
AbstractServerConnection.ConduitState
Nested classes/interfaces inherited from class io.undertow.server.ServerConnection
ServerConnection.CloseListener
-
Field Summary
Fields inherited from class io.undertow.server.AbstractServerConnection
bufferPool, channel, closeListeners, closeSetter, current, extraBytes, originalSinkConduit, originalSourceConduit, rootHandler, undertowOptions
Fields inherited from interface org.xnio.channels.Configurable
EMPTY
-
Constructor Summary
ConstructorsConstructorDescriptionHttpServerConnection
(org.xnio.StreamConnection channel, ByteBufferPool bufferPool, HttpHandler rootHandler, org.xnio.OptionMap undertowOptions, int bufferSize, ConnectorStatisticsImpl connectorStatistics) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
exchangeComplete
(HttpServerExchange exchange) Invoked when the exchange is complete.io.undertow.server.protocol.http.HttpResponseConduit
protected org.xnio.conduits.StreamSinkConduit
getSinkConduit
(HttpServerExchange exchange, org.xnio.conduits.StreamSinkConduit conduit) Gets the sink conduit that should be used for this request.Gets the SSLSession of the underlying connection, or null if SSL is not in use.Gets SSL information about the connection.Returns a string representation describing the protocol used to transmit messages on this connection.protected HttpUpgradeListener
protected boolean
boolean
boolean
protected boolean
sendOutOfBandResponse
(HttpServerExchange exchange) Sends an out of band response, such as a HTTP 100-continue response.protected void
setConnectListener
(HttpUpgradeListener connectListener) void
setPipelineBuffer
(PipeliningBufferingStreamSinkConduit pipelineBuffer) void
setSslSessionInfo
(SSLSessionInfo sessionInfo) Sets the current SSL information.protected void
setUpgradeListener
(HttpUpgradeListener upgradeListener) void
terminateRequestChannel
(HttpServerExchange exchange) Invoked when the exchange is complete, and there is still data in the request channel.void
Pushes back the given data.protected org.xnio.StreamConnection
Upgrade the connection, if allowedMethods inherited from class io.undertow.server.AbstractServerConnection
addCloseListener, clearChannel, close, getBufferPool, getBufferSize, getByteBufferPool, getChannel, getCloseSetter, getExtraBytes, getIoThread, getLocalAddress, getLocalAddress, getOption, getOriginalSinkConduit, getOriginalSourceConduit, getPeerAddress, getPeerAddress, getRootHandler, getSinkChannel, getSourceChannel, getUndertowOptions, getWorker, isOpen, maxEntitySizeUpdated, resetChannel, restoreChannel, setExtraBytes, setOption, sink, source, supportsOption
Methods inherited from class io.undertow.server.ServerConnection
isPushSupported, pushResource, pushResource
Methods inherited from class io.undertow.util.AbstractAttachable
addToAttachmentList, createAttachmentMap, getAttachment, getAttachmentList, putAttachment, removeAttachment
-
Constructor Details
-
HttpServerConnection
public HttpServerConnection(org.xnio.StreamConnection channel, ByteBufferPool bufferPool, HttpHandler rootHandler, org.xnio.OptionMap undertowOptions, int bufferSize, ConnectorStatisticsImpl connectorStatistics)
-
-
Method Details
-
sendOutOfBandResponse
Description copied from class:ServerConnection
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.- Specified by:
sendOutOfBandResponse
in classServerConnection
- Parameters:
exchange
- The current exchange- Returns:
- The out of band exchange.
-
isContinueResponseSupported
public boolean isContinueResponseSupported()- Specified by:
isContinueResponseSupported
in classServerConnection
- Returns:
true
if this connection supports sending a 100-continue response
-
terminateRequestChannel
Description copied from class:ServerConnection
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.- Specified by:
terminateRequestChannel
in classServerConnection
- Parameters:
exchange
- The current exchange.
-
ungetRequestBytes
Pushes back the given data. This should only be used by transfer coding handlers that have read past the end of the request when handling pipelined requests- Parameters:
unget
- The buffer to push back
-
getSslSessionInfo
Description copied from class:ServerConnection
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.- Specified by:
getSslSessionInfo
in classServerConnection
- Returns:
- SSL information about the connection
-
setSslSessionInfo
Description copied from class:ServerConnection
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.- Specified by:
setSslSessionInfo
in classServerConnection
- Parameters:
sessionInfo
- The ssl session information
-
getSslSession
Description copied from class:ServerConnection
Gets the SSLSession of the underlying connection, or null if SSL is not in use. Note that for client cert authServerConnection.getSslSessionInfo()
should be used instead, as it takes into account other information potentially provided by load balancers that terminate SSL- Overrides:
getSslSession
in classServerConnection
- Returns:
- The SSLSession of the connection
-
upgradeChannel
protected org.xnio.StreamConnection upgradeChannel()Description copied from class:ServerConnection
Upgrade the connection, if allowed- Specified by:
upgradeChannel
in classServerConnection
- Returns:
- The StreamConnection that should be passed to the upgrade handler
-
getSinkConduit
protected org.xnio.conduits.StreamSinkConduit getSinkConduit(HttpServerExchange exchange, org.xnio.conduits.StreamSinkConduit conduit) Description copied from class:ServerConnection
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.- Specified by:
getSinkConduit
in classServerConnection
- Returns:
- The source conduit
-
isUpgradeSupported
protected boolean isUpgradeSupported()- Specified by:
isUpgradeSupported
in classServerConnection
- Returns:
- true if this connection supports HTTP upgrade
-
isConnectSupported
protected boolean isConnectSupported()- Specified by:
isConnectSupported
in classServerConnection
- Returns:
true
if this connection supports the HTTP CONNECT verb
-
exchangeComplete
Description copied from class:ServerConnection
Invoked when the exchange is complete.- Specified by:
exchangeComplete
in classServerConnection
-
getPipelineBuffer
-
getResponseConduit
public io.undertow.server.protocol.http.HttpResponseConduit getResponseConduit() -
getUpgradeListener
-
setUpgradeListener
- Overrides:
setUpgradeListener
in classAbstractServerConnection
-
setConnectListener
- Specified by:
setConnectListener
in classServerConnection
-
setPipelineBuffer
-
getTransportProtocol
Description copied from class:ServerConnection
Returns a string representation describing the protocol used to transmit messages on this connection.- Specified by:
getTransportProtocol
in classServerConnection
- Returns:
- the transport protocol
-
isRequestTrailerFieldsSupported
public boolean isRequestTrailerFieldsSupported()- Specified by:
isRequestTrailerFieldsSupported
in classServerConnection
-