Top Description Inners Fields Constructors Methods
org.glassfish.grizzly.http2

public Class Http2Session

extends Object
Class Inheritance
Imports
java.io.IOException, java.util.ArrayList, .Iterator, .List, .Map, .TreeMap, java.util.concurrent.atomic.AtomicInteger, java.util.concurrent.locks.ReentrantLock, java.util.logging.Level, .Logger, org.glassfish.grizzly.Buffer, .CloseListener, .CloseType, .Closeable, .Connection, .Context, .EmptyCompletionHandler, .Grizzly, .IOEvent, .IOEventLifeCycleListener, .ProcessorExecutor, .WriteResult, org.glassfish.grizzly.filterchain.FilterChain, .FilterChainContext, org.glassfish.grizzly.http.HttpContent, .HttpContext, .HttpHeader, .HttpPacket, .HttpRequestPacket, .HttpResponsePacket, .Method, .Protocol, org.glassfish.grizzly.http.util.MimeHeaders, org.glassfish.grizzly.http2.frames.ContinuationFrame, .DataFrame, .ErrorCode, .GoAwayFrame, .HeaderBlockFragment, .HeadersFrame, .Http2Frame, .PingFrame, .PriorityFrame, .PushPromiseFrame, .RstStreamFrame, .SettingsFrame, .SettingsFrame.SettingsFrameBuilder, .UnknownFrame, .WindowUpdateFrame, org.glassfish.grizzly.impl.FutureImpl, org.glassfish.grizzly.memory.Buffers, .MemoryManager, org.glassfish.grizzly.ssl.SSLBaseFilter, org.glassfish.grizzly.utils.Futures, .Holder

The HTTP2 session abstraction.
Author
Alexey Stashok

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private final Holder<?>
private int
private volatile CloseType
closeFlag

References Deprecated CloseType is deprecated or references (maybe indirectly) at least one deprecated element.
private final AtomicInteger
private final Connection<?>
private final ReentrantLock
private int
pack-priv final Http2BaseFilter
private HeadersDecoder
private HeadersEncoder
private volatile FilterChain
private final Http2Configuration
pack-priv Http2State
private volatile FilterChain
private boolean
private volatile boolean
private volatile boolean
private final boolean
private int
pack-priv int
private volatile int
private volatile int
private final int
private volatile int
private static final Logger
private volatile int
private final ReentrantLock
private final Http2SessionOutputSink
private int
private int
private int
private boolean
private FutureImpl<Http2Session>
private final Object
private volatile SSLBaseFilter
private volatile int
private final TreeMap<Integer, Http2Stream>
pack-priv final List<Http2Stream>
protected final List<Http2Frame>
private final AtomicInteger

Constructor Summary

AccessConstructor and Description
public
Http2Session(final Connection<?> connection, final boolean isServer, final Http2BaseFilter handlerFilter)

Method Summary

Modifier and TypeMethod and Description
pack-priv Http2Stream
acceptStream(final HttpRequestPacket request, final int streamId, final int parentStreamId, final boolean exclusive, final int priority)

public Http2Stream

Returns:

a new Http2Stream for this request
acceptUpgradeStream
(final HttpRequestPacket
the request that initiated the upgrade
request
,
final int
the stream priority
priority
,
final boolean
is more content expected?
fin
)

The method is called to create an Http2Stream initiated via HTTP/1.1 Upgrade mechanism.

pack-priv void
ackConsumedData(final int
size, in bytes, of the data being acknowledged
sz
)

Acknowledge that certain amount of data has been read.

pack-priv void
ackConsumedData(final Http2Stream
the stream that data is being ack'd on.
stream
,
final int
size, in bytes, of the data being acknowledged
sz
)

Acknowledge that certain amount of data has been read.

pack-priv static void
bind(final Connection<L> connection, final Http2Session http2Session)

private List<Http2Frame>

Returns:

the result List with the frames
bufferToHeaderFrames
(final int
the stream associated with the headers.
streamId
,
final Buffer
a Buffer containing compressed headers
compressedHeaders
,
final boolean
will any additional data be sent after these headers?
isEos
,
final List<Http2Frame>
the List to which Http2Frames will be added
toList
)

Encodes a compressed header buffer as a HeadersFrame and a sequence of 0 or more ContinuationFrames.

private List<Http2Frame>

Returns:

the result List with the frames
bufferToPushPromiseFrames
(final int
the stream associated with these headers
streamId
,
final int
the stream of the push promise
promisedStreamId
,
final Buffer
the compressed headers to be sent
compressedHeaders
,
final List<Http2Frame>
the List to which Http2Frames will be added
toList
)

Encodes a compressed header buffer as a PushPromiseFrame and a sequence of 0 or more ContinuationFrames.

protected void
private List<Http2Frame>

Returns:

the result List with the frames
completeHeadersProviderFrameSerialization
(final HeaderBlockFragment.HeaderBlockFragmentBuilder<T extends HeaderBlockFragment.HeaderBlockFragmentBuilder> builder, final int
the stream associated with this HeaderBlockFragment
streamId
,
final Buffer
the Buffer containing the compressed headers
compressedHeaders
,
List<Http2Frame>
the List to which Http2Frames will be added
toList
)

Completes the HeaderBlockFragment sequence serialization.

private void
pack-priv void
deregisterStream()

Called from Http2Stream once stream is completely closed.

protected List<Http2Frame>

Returns:

the HTTP2 header frames sequence
encodeHttpHeaderAsHeaderFrames
(final FilterChainContext
the current FilterChainContext
ctx
,
final HttpHeader
the HttpHeader to encode
httpHeader
,
final int
the stream associated with this request
streamId
,
final boolean
is this the last frame?
isLast
,
final List<Http2Frame>
the target List, to which the frames will be serialized
toList
,
final Map<String, String> capture)

Encodes the HttpHeader and locks the compression lock.

protected List<Http2Frame>

Returns:

the HTTP2 push promise frames sequence
encodeHttpRequestAsPushPromiseFrames
(final FilterChainContext
the current FilterChainContext
ctx
,
final HttpRequestPacket
the HttpRequestPacket to encode.
httpRequest
,
final int
the stream associated with this request.
streamId
,
final int
the push promise stream ID.
promisedStreamId
,
final List<Http2Frame>
the target List, to which the frames will be serialized
toList
,
final Map<String, String> capture)

Encodes the HttpRequestPacket as a PushPromiseFrame and locks the compression lock.

protected List<Http2Frame>

Returns:

the HTTP2 header frames sequence
encodeInterimResponseAsHeaderFrames
(final FilterChainContext
the current FilterChainContext
ctx
,
final HttpResponsePacket
the HttpResponsePacket whose interim status and headers are to be encoded
response
,
final int
the stream associated with this response
streamId
,
final List<Http2Frame>
the target List, to which the frames will be serialized
toList
,
final Map<String, String>
optional map collecting the encoded headers for logging
capture
)

Encodes an informational (1xx) interim response, such as 103 Early Hints, as HTTP/2 HEADERS frames.

protected List<Http2Frame>

Returns:

the HTTP2 header frames sequence
encodeTrailersAsHeaderFrames
(final int
the stream associated with this request
streamId
,
final List<Http2Frame>
the target List, to which the frames will be serialized.
toList
,
final MimeHeaders
a MimeHeaders of headers to be transmitted as trailers.
trailerHeaders
,
final Map<String, String> capture)

Encodes the Map of header values into header frames to be sent as trailer headers.

public static Http2Session
get(final Connection<L> connection)

public int
public Connection<L>
public int
public int
public int
pack-priv ReentrantLock
protected int

Returns:

the total frame size (including header size), or -1 if the buffer doesn't contain enough bytes to read the size
getFrameSize
(final Buffer
the buffer containing the frame data
buffer
)

Returns the total frame size (including header size), or -1 if the buffer doesn't contain enough bytes to read the size.

public int
pack-priv HeadersDecoder
pack-priv HeadersEncoder
pack-priv FilterChain
pack-priv Http2State
public int
public int
getLocalMaxConcurrentStreams()

Returns: the maximum number of concurrent streams allowed for this session by our side.

public final int
getLocalMaxFramePayloadSize()

Returns: The max payload size to be accepted by this side

public int
public int
getMaxHeaderListSize()

Returns: the maximum size, in bytes, of header list.

public MemoryManager<E extends Buffer>
public ReentrantLock

Returns:

the ReentrantLock
getNewClientStreamLock
()

The ReentrantLock, which assures that requests assigned to newly allocated stream IDs will be sent to the server in their order.

public int
protected Http2SessionOutputSink
public int
getPeerMaxConcurrentStreams()

Returns: the maximum number of concurrent streams allowed for this session by peer.

public int
getPeerMaxFramePayloadSize()

Returns: The max payload size to be accepted by the peer

public int
protected int
protected int
protected int
public Http2Stream
getStream(final int streamId)

private void
private boolean
pack-priv boolean
pack-priv boolean
pack-priv boolean
public boolean
isLocallyInitiatedStream(final int streamId)

pack-priv boolean
public boolean
isPushEnabled()

Returns: true if push is enabled for this Http2Session, otherwise returns false.

public boolean
protected Http2SessionOutputSink
protected Http2Stream
newStream(final HttpRequestPacket request, final int streamId, final int refStreamId, final boolean exclusive, final int priority)

protected Http2Stream
newUpgradeStream(final HttpRequestPacket request, final int priority)

protected void
onOversizedFrame(final Buffer buffer)

public Http2Stream

Returns:

a new Http2Stream for this request
openStream
(final HttpRequestPacket
the request that initiated the stream
request
,
final int
the ID of this new stream
streamId
,
final int
the parent stream
parentStreamId
,
final boolean exclusive, final int
the priority of this stream
priority
)

Method is not thread-safe, it is expected that it will be called within getNewClientStreamLock() lock scope.

public Http2Stream

Returns:

a new Http2Stream for this request
openUpgradeStream
(final HttpRequestPacket
the request that initiated the upgrade
request
,
final int
the priority of the stream
priority
)

The method is called on the client side, when the server confirms HTTP/1.1 -> HTTP/2.0 upgrade with '101' response.

public Http2Frame
protected SettingsFrame.SettingsFrameBuilder
private void
pack-priv void
registerStream(final int streamId, final Http2Stream stream)

private void
protected void
private void
pack-priv void
sendMessageUpstream(final Http2Stream stream, final HttpPacket message)

private void
sendMessageUpstream(final Http2Stream stream, final HttpPacket message, final FilterChainContext upstreamContext)

pack-priv void
pack-priv void
protected void
protected void
sendWindowUpdate(final int streamId, final int delta)

pack-priv void
setGoAwayByPeer(final int lastStreamId)

Method is called, when GOAWAY is initiated by peer

private GoAwayFrame
setGoAwayLocally(final ErrorCode errorCode, final String detail, final boolean graceful)

public void
setLocalConnectionWindowSize(final int localConnectionWindowSize)

public void
setLocalMaxConcurrentStreams(int
max number of streams locally allowed
localMaxConcurrentStreams
)

Sets the default maximum number of concurrent streams allowed for this session by our side.

public void
setLocalStreamWindowSize(int localStreamWindowSize)

public void
setMaxHeaderListSize(int
size, in bytes, of the header list.
maxHeaderListSize
)

Set the maximum size, in bytes, of the header list.

pack-priv void
setPeerMaxConcurrentStreams(int peerMaxConcurrentStreams)

Sets the default maximum number of concurrent streams allowed for this session by peer.

protected void
setPeerMaxFramePayloadSize(final int
max payload size accepted by the peer.
peerMaxFramePayloadSize
)

Sets the max payload size to be accepted by the peer.

pack-priv void
setPeerStreamWindowSize(final int peerStreamWindowSize)

public void
setPushEnabled(final boolean
flag toggling push support.
pushEnabled
)

Configure whether or not push is enabled on this Http2Session.

pack-priv void
setupFilterChains(final FilterChainContext
the current FilterChainContext
context
,
final boolean
flag denoting the direction of the chain
isUpStream
)

Initializes HTTP2 communication (if not initialized before) by forming HTTP2 connection and stream FilterChains.

pack-priv void
terminate(final ErrorCode
an RFC 7540 error code.
errorCode
,
final String
optional details.
detail
)

Terminate the HTTP2 session sending a GOAWAY frame using the specified error code and optional detail.

pack-priv FutureImpl<Http2Session>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait