Top Description Inners Fields Constructors Methods
io.undertow.protocols.http2

public Class Http2Channel

extends AbstractFramedChannel<Http2Channel, AbstractHttp2StreamSourceChannel, AbstractHttp2StreamSinkChannel>
implements Attachable
Class Inheritance
All Implemented Interfaces
io.undertow.util.Attachable
Imports
io.undertow.UndertowLogger, .UndertowMessages, .UndertowOptions, io.undertow.connector.ByteBufferPool, .PooledByteBuffer, io.undertow.server.protocol.ParseTimeoutUpdater, io.undertow.server.protocol.framed.AbstractFramedChannel, .AbstractFramedStreamSourceChannel, .FrameHeaderData, io.undertow.server.protocol.http2.Http2OpenListener, io.undertow.util.Attachable, .AttachmentKey, .AttachmentList, .HeaderMap, .HttpString, org.xnio.Bits, .ChannelExceptionHandler, .ChannelListener, .ChannelListeners, .IoUtils, .OptionMap, .StreamConnection, org.xnio.channels.StreamSinkChannel, org.xnio.ssl.SslConnection, javax.net.ssl.SSLSession, java.io.IOException, java.nio.ByteBuffer, java.nio.channels.Channel, .ClosedChannelException, java.security.SecureRandom, java.util.ArrayList, .Collection, .Collections, .HashMap, .Iterator, .List, .Map, .Queue, .Random, java.util.concurrent.ConcurrentHashMap, .ConcurrentLinkedQueue, .TimeUnit, java.util.concurrent.atomic.AtomicIntegerFieldUpdater

HTTP2 channel.
Author
Stuart Douglas

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private static class
private static class
private static class

Field Summary

Modifier and TypeField and Description
private final Map<AttachmentKey<?>, Object>
public static final HttpString
public static final String
pack-priv static final int
private Http2HeadersParser
private final Map<Integer, Http2Channel.StreamHolder>
pack-priv static final int
pack-priv static final int
pack-priv static final int
private final HpackDecoder
public static final int
public static final int
private final HpackEncoder
private final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
private final Object
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
private Http2FrameHeaderParser
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
private final int
private volatile int
initialSendWindowSize

The initial window size for newly created channels, guarded by flowControlLock

private boolean
private boolean
initialSettingsSent

We send the settings frame lazily, which is basically a big hack to work around broken IE support for push (it dies if you send a settings frame with push enabled).

private int
private boolean
private int
private long
public static final int
private final int
private final int
private final int
private final int
public static final HttpString
private final Random
private final ParseTimeoutUpdater
public static final HttpString
private boolean
pack-priv static final int
pack-priv static final int
pack-priv static final byte[]
private int
private final String
private volatile boolean
private volatile int
private static final AtomicIntegerFieldUpdater<Http2Channel>
private int
private final int
private final int
private volatile int
receiveWindowSize

How much data we have told the remote endpoint we are prepared to accept, guarded by flowControlLock

private final long
public static final HttpString
private volatile int
private static final AtomicIntegerFieldUpdater<Http2Channel>
private volatile int
private volatile int
private volatile long
sendWindowSize

How much data we can send to the remote endpoint, at the connection level, guarded by flowControlLock

private final Http2Channel.StreamCache
pack-priv static final int
public static final HttpString
private static final int
private int
private boolean
private int

Constructor Summary

AccessConstructor and Description
public
Http2Channel(StreamConnection connectedStreamChannel, String protocol, ByteBufferPool bufferPool, PooledByteBuffer data, boolean clientSide, boolean fromUpgrade, OptionMap settings)

public
Http2Channel(StreamConnection connectedStreamChannel, String protocol, ByteBufferPool bufferPool, PooledByteBuffer data, boolean clientSide, boolean fromUpgrade, boolean prefaceRequired, OptionMap settings)

public
Http2Channel(StreamConnection connectedStreamChannel, String protocol, ByteBufferPool bufferPool, PooledByteBuffer data, boolean clientSide, boolean fromUpgrade, boolean prefaceRequired, ByteBuffer initialOtherSideSettings, OptionMap settings)

Method Summary

Modifier and TypeMethod and Description
public synchronized boolean

Returns:

true if pushedStreamId can be added, false if invalid
addPushPromiseStream
(int
The pushed stream returned by the server
pushedStreamId
)

Adds a received pushed stream into the current streams for a client.

public <T> void
addToAttachmentList(AttachmentKey<AttachmentList<T>>
the attachment key
key
,
T
the value to add
value
)

Implements io.undertow.util.Attachable.addToAttachmentList.

Add a value to a list-typed attachment key.

protected void
closeSubChannels()

Implements abstract io.undertow.server.protocol.framed.AbstractFramedChannel.closeSubChannels.

Method that is called when the channel is being forcibly closed, and all sub stream sink/source channels should also be forcibly closed.

private void
protected AbstractHttp2StreamSourceChannel
createChannel(FrameHeaderData
The header data, as returned by parseFrame(java.nio.ByteBuffer)
frameHeaderData
,
PooledByteBuffer
Any additional data for the frame that has already been read. This may not be the complete frame contents
frameData
)

Implements abstract io.undertow.server.protocol.framed.AbstractFramedChannel.createChannel.

Method that creates the actual stream source channel implementation that is in use.

protected AbstractHttp2StreamSourceChannel
public synchronized Http2HeadersStreamSinkChannel
createInitialUpgradeResponseStream()

Creates a response stream to respond to the initial HTTP upgrade

public synchronized Http2HeadersStreamSinkChannel
createStream(HeaderMap requestHeaders)

Creates a strema using a HEADERS frame

private void
private void
public <T> T
getAttachment(AttachmentKey<T>
the attachment key
key
)

Implements io.undertow.util.Attachable.getAttachment.

Get an attachment value.

public <T> List<T>
getAttachmentList(AttachmentKey<? extends List<T>>
the attachment key
key
)

Implements io.undertow.util.Attachable.getAttachmentList.

Gets a list attachment value.

pack-priv HpackDecoder
pack-priv HpackEncoder
public int
pack-priv Http2StreamSourceChannel
getIncomingStream(int streamId)

public int
public int
private synchronized int
private synchronized int
pack-priv int
pack-priv int
pack-priv int
public String
public String
public int
public int
protected Collection<AbstractFramedStreamSourceChannel<Http2Channel, AbstractHttp2StreamSourceChannel, AbstractHttp2StreamSinkChannel>>
public int
public int
public SSLSession
pack-priv int

Returns:

The actual amount of bytes the sender can send
grabFlowControlBytes
(int
The amount of bytes the sender is trying to send
bytesToGrab
)

Try and decrement the send window by the given amount of bytes.

protected void
handleBrokenSinkChannel(Throwable e)

Implements abstract io.undertow.server.protocol.framed.AbstractFramedChannel.handleBrokenSinkChannel.

Method that is invoked when then write side of a channel is broken.

protected void
handleBrokenSourceChannel(Throwable e)

Implements abstract io.undertow.server.protocol.framed.AbstractFramedChannel.handleBrokenSourceChannel.

Method that is invoked when the read side of the channel is broken.

private Http2Channel.StreamHolder
handleRstStream(int streamId, boolean receivedRst)

public void
handleWindowUpdate(int streamId, int deltaWindowSize)

public boolean
private synchronized boolean
isIdle(int streamNo)

protected boolean
isLastFrameReceived()

Implements abstract io.undertow.server.protocol.framed.AbstractFramedChannel.isLastFrameReceived.

Returns true if the protocol specific final frame has been received.

protected boolean
public boolean
public boolean
public boolean
protected void
lastDataRead()

Overrides io.undertow.server.protocol.framed.AbstractFramedChannel.lastDataRead.

Method than is invoked when read() returns -1.

pack-priv synchronized void
protected FrameHeaderData
parseFrame(ByteBuffer
The data that has been read from the channel
data
)

Implements abstract io.undertow.server.protocol.framed.AbstractFramedChannel.parseFrame.

Attempts to parse an incoming frame header from the data in the buffer.

private Http2FrameHeaderParser
public <T> T
putAttachment(AttachmentKey<T>
the attachment key
key
,
T
the new value
value
)

Implements io.undertow.util.Attachable.putAttachment.

Set an attachment value.

pack-priv void
public <T> T
removeAttachment(AttachmentKey<T>
the attachment key
key
)

Implements io.undertow.util.Attachable.removeAttachment.

Remove an attachment, returning its previous value.

pack-priv void
removeStreamSink(int streamId)

pack-priv Http2StreamSourceChannel
removeStreamSource(int streamId)

public void
sendGoAway(int status)

public void
public void
sendPing(byte[] data)

public void
sendPing(byte[] data, final ChannelExceptionHandler<AbstractHttp2StreamSinkChannel> exceptionHandler)

pack-priv void
sendPing(byte[] data, final ChannelExceptionHandler<AbstractHttp2StreamSinkChannel> exceptionHandler, boolean ack)

private void
public synchronized Http2HeadersStreamSinkChannel
sendPushPromise(int associatedStreamId, HeaderMap requestHeaders, HeaderMap responseHeaders)

public void
sendRstStream(int streamId, int statusCode)

private void
private void
public void
sendUpdateWindowSize(int streamId, int delta)

public void
setSendMaxConcurrentStreams(int sendMaxConcurrentStreams)

public void
pack-priv boolean
updateSettings(List<Http2Setting> settings)

Setting have been received from the client

private synchronized void
updateStreamIdsCountersInHeaders(int
The received streamId for the client or the server
streamNo
)

Updates the lastGoodStreamId (last request ID to send in goaway frames), and lastAssignedStreamOtherSide (the last received streamId from the other side to check if it's idle).

Inherited from io.undertow.server.protocol.framed.AbstractFramedChannel:
addCloseTaskclosecreateIdleTimeoutChannelflushflushSendersgetBufferPoolgetCloseSettergetDestinationAddressgetFramePrioritygetIdleTimeoutgetIoThreadgetLocalAddressgetLocalAddressgetOptiongetPeerAddressgetPeerAddressgetReceiveSettergetSettingsgetSourceAddressgetUnderlyingConnectiongetWorkerisOpenisReadsBrokenisReceivesResumedisRequireExplicitFlushisWritesBrokenmarkReadsBrokenmarkWritesBrokenqueueFramerecalculateHeldFramesreceiveresumeReceivessetIdleTimeoutsetOptionsetRequireExplicitFlushsupportsOptionsuspendReceivestoStringwriteExceptionHandler