Package io.undertow.protocols.http2
Class Http2Channel
java.lang.Object
io.undertow.server.protocol.framed.AbstractFramedChannel<Http2Channel,AbstractHttp2StreamSourceChannel,AbstractHttp2StreamSinkChannel>
io.undertow.protocols.http2.Http2Channel
- All Implemented Interfaces:
Attachable,Closeable,AutoCloseable,Channel,InterruptibleChannel,org.xnio.channels.BoundChannel,org.xnio.channels.CloseableChannel,org.xnio.channels.Configurable,org.xnio.channels.ConnectedChannel
public class Http2Channel
extends AbstractFramedChannel<Http2Channel,AbstractHttp2StreamSourceChannel,AbstractHttp2StreamSinkChannel>
implements Attachable
HTTP2 channel.
- Author:
- Stuart Douglas
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final HttpStringstatic final Stringstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final StringName of the system property for configuring HTTP2 max header size:"io.undertow.http2-max-header-size".static final intstatic final HttpStringstatic final HttpStringstatic final HttpStringstatic final HttpStringFields inherited from interface org.xnio.channels.Configurable
EMPTY -
Constructor Summary
ConstructorsConstructorDescriptionHttp2Channel(org.xnio.StreamConnection connectedStreamChannel, String protocol, ByteBufferPool bufferPool, PooledByteBuffer data, boolean clientSide, boolean fromUpgrade, boolean prefaceRequired, ByteBuffer initialOtherSideSettings, org.xnio.OptionMap settings) Http2Channel(org.xnio.StreamConnection connectedStreamChannel, String protocol, ByteBufferPool bufferPool, PooledByteBuffer data, boolean clientSide, boolean fromUpgrade, boolean prefaceRequired, org.xnio.OptionMap settings) Http2Channel(org.xnio.StreamConnection connectedStreamChannel, String protocol, ByteBufferPool bufferPool, PooledByteBuffer data, boolean clientSide, boolean fromUpgrade, org.xnio.OptionMap settings) -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddPushPromiseStream(int pushedStreamId) Adds a received pushed stream into the current streams for a client.<T> voidaddToAttachmentList(AttachmentKey<AttachmentList<T>> key, T value) Add a value to a list-typed attachment key.protected voidMethod that is called when the channel is being forcibly closed, and all sub stream sink/source channels should also be forcibly closed.protected AbstractHttp2StreamSourceChannelcreateChannel(FrameHeaderData frameHeaderData, PooledByteBuffer frameData) Method that creates the actual stream source channel implementation that is in use.protected AbstractHttp2StreamSourceChannelcreateChannelImpl(FrameHeaderData frameHeaderData, PooledByteBuffer frameData) Creates a response stream to respond to the initial HTTP upgradecreateStream(HeaderMap requestHeaders) Creates a strema using a HEADERS frame<T> TgetAttachment(AttachmentKey<T> key) Get an attachment value.<T> List<T>getAttachmentList(AttachmentKey<? extends List<T>> key) Gets a list attachment value.intintintintintprotected Collection<AbstractFramedStreamSourceChannel<Http2Channel,AbstractHttp2StreamSourceChannel, AbstractHttp2StreamSinkChannel>> intintprotected voidMethod that is invoked when then write side of a channel is broken.protected voidMethod that is invoked when the read side of the channel is broken.voidhandleWindowUpdate(int streamId, int deltaWindowSize) booleanisClient()protected booleanReturns true if the protocol specific final frame has been received.protected booleanbooleanbooleanbooleanprotected voidMethod than is invoked when read() returns -1.protected FrameHeaderDataparseFrame(ByteBuffer data) Attempts to parse an incoming frame header from the data in the buffer.<T> TputAttachment(AttachmentKey<T> key, T value) Set an attachment value.<T> TremoveAttachment(AttachmentKey<T> key) Remove an attachment, returning its previous value.voidsendGoAway(int status) voidsendGoAway(int status, org.xnio.ChannelExceptionHandler<AbstractHttp2StreamSinkChannel> exceptionHandler) voidsendPing(byte[] data) voidsendPing(byte[] data, org.xnio.ChannelExceptionHandler<AbstractHttp2StreamSinkChannel> exceptionHandler) sendPushPromise(int associatedStreamId, HeaderMap requestHeaders, HeaderMap responseHeaders) voidsendRstStream(int streamId, int statusCode) voidsendUpdateWindowSize(int streamId, int delta) voidsetSendMaxConcurrentStreams(int sendMaxConcurrentStreams) voidupdateReceiveFlowControlWindow(int read) Methods inherited from class io.undertow.server.protocol.framed.AbstractFramedChannel
addCloseTask, close, createIdleTimeoutChannel, flush, flushSenders, getBufferPool, getCloseSetter, getDestinationAddress, getFramePriority, getIdleTimeout, getIoThread, getLocalAddress, getLocalAddress, getOption, getPeerAddress, getPeerAddress, getReceiveSetter, getSettings, getSourceAddress, getUnderlyingConnection, getWorker, isOpen, isReadsBroken, isReceivesResumed, isRequireExplicitFlush, isWritesBroken, markReadsBroken, markWritesBroken, queueFrame, recalculateHeldFrames, receive, resumeReceives, setIdleTimeout, setOption, setRequireExplicitFlush, supportsOption, suspendReceives, toString, writeExceptionHandler
-
Field Details
-
HTTP2_MAX_HEADER_SIZE_PROPERTY
Name of the system property for configuring HTTP2 max header size:"io.undertow.http2-max-header-size".This system property will be replaced by an
Undertow option.- See Also:
-
CLEARTEXT_UPGRADE_STRING
- See Also:
-
METHOD
-
PATH
-
SCHEME
-
AUTHORITY
-
STATUS
-
ERROR_NO_ERROR
public static final int ERROR_NO_ERROR- See Also:
-
ERROR_PROTOCOL_ERROR
public static final int ERROR_PROTOCOL_ERROR- See Also:
-
ERROR_INTERNAL_ERROR
public static final int ERROR_INTERNAL_ERROR- See Also:
-
ERROR_FLOW_CONTROL_ERROR
public static final int ERROR_FLOW_CONTROL_ERROR- See Also:
-
ERROR_SETTINGS_TIMEOUT
public static final int ERROR_SETTINGS_TIMEOUT- See Also:
-
ERROR_STREAM_CLOSED
public static final int ERROR_STREAM_CLOSED- See Also:
-
ERROR_FRAME_SIZE_ERROR
public static final int ERROR_FRAME_SIZE_ERROR- See Also:
-
ERROR_REFUSED_STREAM
public static final int ERROR_REFUSED_STREAM- See Also:
-
ERROR_CANCEL
public static final int ERROR_CANCEL- See Also:
-
ERROR_COMPRESSION_ERROR
public static final int ERROR_COMPRESSION_ERROR- See Also:
-
ERROR_CONNECT_ERROR
public static final int ERROR_CONNECT_ERROR- See Also:
-
ERROR_ENHANCE_YOUR_CALM
public static final int ERROR_ENHANCE_YOUR_CALM- See Also:
-
ERROR_INADEQUATE_SECURITY
public static final int ERROR_INADEQUATE_SECURITY- See Also:
-
DEFAULT_INITIAL_WINDOW_SIZE
public static final int DEFAULT_INITIAL_WINDOW_SIZE- See Also:
-
DEFAULT_MAX_FRAME_SIZE
public static final int DEFAULT_MAX_FRAME_SIZE- See Also:
-
MAX_FRAME_SIZE
public static final int MAX_FRAME_SIZE- See Also:
-
FLOW_CONTROL_MIN_WINDOW
public static final int FLOW_CONTROL_MIN_WINDOW- See Also:
-
-
Constructor Details
-
Http2Channel
public Http2Channel(org.xnio.StreamConnection connectedStreamChannel, String protocol, ByteBufferPool bufferPool, PooledByteBuffer data, boolean clientSide, boolean fromUpgrade, org.xnio.OptionMap settings) -
Http2Channel
public Http2Channel(org.xnio.StreamConnection connectedStreamChannel, String protocol, ByteBufferPool bufferPool, PooledByteBuffer data, boolean clientSide, boolean fromUpgrade, boolean prefaceRequired, org.xnio.OptionMap settings) -
Http2Channel
public Http2Channel(org.xnio.StreamConnection connectedStreamChannel, String protocol, ByteBufferPool bufferPool, PooledByteBuffer data, boolean clientSide, boolean fromUpgrade, boolean prefaceRequired, ByteBuffer initialOtherSideSettings, org.xnio.OptionMap settings)
-
-
Method Details
-
createChannel
protected AbstractHttp2StreamSourceChannel createChannel(FrameHeaderData frameHeaderData, PooledByteBuffer frameData) throws IOException Description copied from class:AbstractFramedChannelMethod that creates the actual stream source channel implementation that is in use.- Specified by:
createChannelin classAbstractFramedChannel<Http2Channel,AbstractHttp2StreamSourceChannel, AbstractHttp2StreamSinkChannel> - Parameters:
frameHeaderData- The header data, as returned byAbstractFramedChannel.parseFrame(java.nio.ByteBuffer)frameData- Any additional data for the frame that has already been read. This may not be the complete frame contents- Returns:
- A new stream source channel
- Throws:
IOException
-
createChannelImpl
protected AbstractHttp2StreamSourceChannel createChannelImpl(FrameHeaderData frameHeaderData, PooledByteBuffer frameData) throws IOException - Throws:
IOException
-
parseFrame
Description copied from class:AbstractFramedChannelAttempts to parse an incoming frame header from the data in the buffer.- Specified by:
parseFramein classAbstractFramedChannel<Http2Channel,AbstractHttp2StreamSourceChannel, AbstractHttp2StreamSinkChannel> - Parameters:
data- The data that has been read from the channel- Returns:
- The frame header data, or
nullif the data was incomplete - Throws:
IOException- If the data could not be parsed.
-
lastDataRead
protected void lastDataRead()Description copied from class:AbstractFramedChannelMethod than is invoked when read() returns -1. -
isLastFrameReceived
protected boolean isLastFrameReceived()Description copied from class:AbstractFramedChannelReturns true if the protocol specific final frame has been received.- Specified by:
isLastFrameReceivedin classAbstractFramedChannel<Http2Channel,AbstractHttp2StreamSourceChannel, AbstractHttp2StreamSinkChannel> - Returns:
trueIf the last frame has been received
-
isLastFrameSent
protected boolean isLastFrameSent()- Specified by:
isLastFrameSentin classAbstractFramedChannel<Http2Channel,AbstractHttp2StreamSourceChannel, AbstractHttp2StreamSinkChannel> - Returns:
trueIf the last frame has been sent
-
handleBrokenSourceChannel
Description copied from class:AbstractFramedChannelMethod that is invoked when the read side of the channel is broken. This generally happens on a protocol error. -
handleBrokenSinkChannel
Description copied from class:AbstractFramedChannelMethod that is invoked when then write side of a channel is broken. This generally happens on a protocol error. -
closeSubChannels
protected void closeSubChannels()Description copied from class:AbstractFramedChannelMethod that is called when the channel is being forcibly closed, and all sub stream sink/source channels should also be forcibly closed.- Specified by:
closeSubChannelsin classAbstractFramedChannel<Http2Channel,AbstractHttp2StreamSourceChannel, AbstractHttp2StreamSinkChannel>
-
getReceivers
protected Collection<AbstractFramedStreamSourceChannel<Http2Channel,AbstractHttp2StreamSourceChannel, getReceivers()AbstractHttp2StreamSinkChannel>> - Specified by:
getReceiversin classAbstractFramedChannel<Http2Channel,AbstractHttp2StreamSourceChannel, AbstractHttp2StreamSinkChannel>
-
getHttp2Version
public int getHttp2Version() -
getInitialSendWindowSize
public int getInitialSendWindowSize() -
getInitialReceiveWindowSize
public int getInitialReceiveWindowSize() -
getSendMaxConcurrentStreams
public int getSendMaxConcurrentStreams() -
setSendMaxConcurrentStreams
public void setSendMaxConcurrentStreams(int sendMaxConcurrentStreams) -
getReceiveMaxConcurrentStreams
public int getReceiveMaxConcurrentStreams() -
handleWindowUpdate
- Throws:
IOException
-
sendPing
public void sendPing(byte[] data) -
sendPing
public void sendPing(byte[] data, org.xnio.ChannelExceptionHandler<AbstractHttp2StreamSinkChannel> exceptionHandler) -
sendGoAway
public void sendGoAway(int status) -
sendGoAway
public void sendGoAway(int status, org.xnio.ChannelExceptionHandler<AbstractHttp2StreamSinkChannel> exceptionHandler) -
sendUpdateWindowSize
- Throws:
IOException
-
getSslSession
-
updateReceiveFlowControlWindow
- Throws:
IOException
-
createStream
Creates a strema using a HEADERS frame- Parameters:
requestHeaders-- Returns:
- Throws:
IOException
-
getProtocolRequestId
-
addPushPromiseStream
Adds a received pushed stream into the current streams for a client. The stream is added into the currentStream and lastAssignedStreamOtherSide is incremented.- Parameters:
pushedStreamId- The pushed stream returned by the server- Returns:
- true if pushedStreamId can be added, false if invalid
- Throws:
IOException- General error like not being a client or odd stream id
-
sendPushPromise
public Http2HeadersStreamSinkChannel sendPushPromise(int associatedStreamId, HeaderMap requestHeaders, HeaderMap responseHeaders) throws IOException - Throws:
IOException
-
isClient
public boolean isClient() -
getAttachment
Description copied from interface:AttachableGet an attachment value. If no attachment exists for this key,nullis returned.- Specified by:
getAttachmentin interfaceAttachable- Type Parameters:
T- the value type- Parameters:
key- the attachment key- Returns:
- the value, or
nullif there is none
-
getAttachmentList
Description copied from interface:AttachableGets a list attachment value. If not attachment exists for this key an empty list is returned- Specified by:
getAttachmentListin interfaceAttachable- Type Parameters:
T- the value type- Parameters:
key- the attachment key- Returns:
- the value, or an empty list if there is none
-
putAttachment
Description copied from interface:AttachableSet an attachment value. If an attachment for this key was already set, return the original value. If the value being set isnull, the attachment key is removed.- Specified by:
putAttachmentin interfaceAttachable- Type Parameters:
T- the value type- Parameters:
key- the attachment keyvalue- the new value- Returns:
- the old value, or
nullif there was none
-
removeAttachment
Description copied from interface:AttachableRemove an attachment, returning its previous value.- Specified by:
removeAttachmentin interfaceAttachable- Type Parameters:
T- the value type- Parameters:
key- the attachment key- Returns:
- the old value, or
nullif there was none
-
addToAttachmentList
Description copied from interface:AttachableAdd a value to a list-typed attachment key. If the key is not mapped, add such a mapping.- Specified by:
addToAttachmentListin interfaceAttachable- Type Parameters:
T- the list value type- Parameters:
key- the attachment keyvalue- the value to add
-
sendRstStream
public void sendRstStream(int streamId, int statusCode) -
createInitialUpgradeResponseStream
Creates a response stream to respond to the initial HTTP upgrade- Returns:
-
isPushEnabled
public boolean isPushEnabled() -
isPeerGoneAway
public boolean isPeerGoneAway() -
isThisGoneAway
public boolean isThisGoneAway() -
getReceiveMaxFrameSize
public int getReceiveMaxFrameSize() -
getSendMaxFrameSize
public int getSendMaxFrameSize() -
getProtocol
-