Top Description Inners Fields Constructors Methods
org.apache.coyote.http2

pack-priv Class Http2UpgradeHandler

extends AbstractStream
implements InternalHttpUpgradeHandler, Input, Output
Class Inheritance
All Implemented Interfaces
org.apache.coyote.http2.Http2Parser.Output, org.apache.coyote.http2.Http2Parser.Input, org.apache.coyote.http11.upgrade.InternalHttpUpgradeHandler, jakarta.servlet.http.HttpUpgradeHandler
Known Direct Subclasses
org.apache.coyote.http2.Http2AsyncUpgradeHandler
Imports
java.io.EOFException, .IOException, java.nio.ByteBuffer, java.nio.charset.StandardCharsets, java.util.Comparator, .HashSet, .Iterator, .Queue, .Set, java.util.concurrent.ConcurrentLinkedQueue, .ConcurrentNavigableMap, .ConcurrentSkipListMap, .ConcurrentSkipListSet, java.util.concurrent.atomic.AtomicInteger, .AtomicLong, .AtomicReference, java.util.concurrent.locks.Lock, jakarta.servlet.ServletConnection, jakarta.servlet.http.WebConnection, org.apache.coyote.Adapter, .ProtocolException, .Request, org.apache.coyote.http11.upgrade.InternalHttpUpgradeHandler, org.apache.coyote.http2.HpackDecoder.HeaderEmitter, .HpackEncoder.State, .Http2Parser.Input, .Http2Parser.Output, org.apache.juli.logging.Log, .LogFactory, org.apache.tomcat.util.codec.binary.Base64, org.apache.tomcat.util.http.MimeHeaders, org.apache.tomcat.util.http.parser.Priority, org.apache.tomcat.util.log.UserDataHelper, org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState, .SSLSupport, .SendfileState, .SocketEvent, .SocketWrapperBase, org.apache.tomcat.util.res.StringManager

This represents an HTTP/2 connection from a client to Tomcat. It is designed on the basis that there will never be more than one thread performing I/O at a time.
For reading, this implementation is blocking within frames and non-blocking between frames.

Note

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum
private class
protected static interface
protected class
protected static class

Field Summary

Modifier and TypeField and Description
protected final AtomicInteger
private final Adapter
private long
private final Set<Stream>
protected final String
private AtomicReference<Http2UpgradeHandler.ConnectionState>
private volatile long
protected static final int
protected static final int
protected static final byte[]
protected static final HeaderSink
private HpackDecoder
private HpackEncoder
private static final String
private volatile int
private volatile int
protected final ConnectionSettingsLocal
localSettings

Local settings are settings defined by Tomcat and sent to the client that the client must use when communicating with Tomcat.

protected static final Log
private volatile int
private volatile int
private volatile int
private final AtomicInteger
private final AtomicLong
private volatile Http2Parser
private volatile long
protected static final byte[]
protected static final byte[]
private final Http2UpgradeHandler.PingManager
protected final Http2Protocol
private Queue<StreamRunnable>
private final ConnectionSettingsRemote
remoteSettings

Remote settings are settings defined by the client and sent to Tomcat that Tomcat must use when communicating with the client.

protected static final byte[]
protected static final StringManager
protected final SocketWrapperBase<?>
private volatile SSLSupport
private static final Integer
private AtomicInteger
private final ConcurrentNavigableMap<Integer, AbstractNonZeroStream>
protected final UserDataHelper
Inherited from org.apache.coyote.http2.AbstractStream:
windowAllocationAvailablewindowAllocationLock

Constructor Summary

AccessConstructor and Description
pack-priv
Http2UpgradeHandler(Http2Protocol protocol, Adapter adapter, Request coyoteRequest, SocketWrapperBase<?> socketWrapper)

Method Summary

Modifier and TypeMethod and Description
private int
allocate(AbstractStream stream, int allocation)

pack-priv void
private void
pack-priv void
private void
closeIdleStreams(int newMaxActiveRemoteStreamId)

private Stream
private Stream
createRemoteStream(int streamId)

protected byte[]

Returns:

The WINDOW_UPDATE frame if one is required or an empty array if no WINDOW_UPDATE is required.
createWindowUpdateForSettings
()

private int
protected void
public void
destroy()

Implements jakarta.servlet.http.HttpUpgradeHandler.destroy.

This method is called after the upgraded connection has been closed.

protected Http2UpgradeHandler.HeaderFrameBuffers
doWriteHeaders(Stream stream, int pushedStreamId, MimeHeaders mimeHeaders, boolean endOfStream, int payloadSize)

public void
pack-priv void
public boolean
fill(boolean
Should the first read into the provided buffer be a blocking read or not.
block
,
byte[]
Buffer to fill
data
,
int
Position in buffer to start writing
offset
,
int
Number of bytes to read
length
)

Implements org.apache.coyote.http2.Http2Parser.Input.fill.

Fill the given array with data unless non-blocking is requested and no data is available.

private AbstractNonZeroStream
private AbstractNonZeroStream
getAbstractNonZeroStream(int streamId, boolean unknownIsError)

protected final String
protected Http2UpgradeHandler.HeaderFrameBuffers
getHeaderFrameBuffers(int initialPayloadSize)

public HpackDecoder
protected HpackEncoder
pack-priv ConnectionSettingsLocal
public int
protected Http2Parser
getParser(String connectionId)

protected Http2UpgradeHandler.PingManager
pack-priv Http2Protocol
pack-priv ConnectionSettingsRemote
public ServletConnection
private Stream
getStream(int streamId)

private Stream
getStream(int streamId, boolean unknownIsError)

private int
public void
goaway(int lastStreamId, long errorCode, String debugData)

Implements org.apache.coyote.http2.Http2Parser.Output.goaway.

protected void
public void
headersContinue(int payloadSize, boolean endOfHeaders)

Implements org.apache.coyote.http2.Http2Parser.Output.headersContinue.

public void
headersEnd(int streamId, boolean endOfStream)

Implements org.apache.coyote.http2.Http2Parser.Output.headersEnd.

public HpackDecoder.HeaderEmitter
headersStart(int streamId, boolean headersEndStream)

Implements org.apache.coyote.http2.Http2Parser.Output.headersStart.

public void
private void
increaseOverheadCount(FrameType frameType, int increment)

private int
protected void
incrementWindowSize(int
The amount by which the window size should be increased
increment
)

Overrides org.apache.coyote.http2.AbstractStream.incrementWindowSize.

Increment window size.

public void
public void
init(WebConnection
The connection that has been upgraded
webConnection
)

Implements jakarta.servlet.http.HttpUpgradeHandler.init.

This method is called once the request/response pair where HttpServletRequest#upgrade(Class) is called has completed processing and is the point where control of the connection passes from the container to the HttpUpgradeHandler.

pack-priv boolean
public void
onSwallowedDataFramePayload(int
The stream on which the payload that has been swallowed was received
streamId
,
int
The number of bytes that the parser swallowed.
swallowedDataBytesCount
)

Implements org.apache.coyote.http2.Http2Parser.Output.onSwallowedDataFramePayload.

Notification triggered when the parser swallows some or all of a DATA frame payload without writing it to the ByteBuffer returned by startRequestBodyFrame(int, int, boolean).

public void
onSwallowedUnknownFrame(int
The stream on which the swallowed frame was received
streamId
,
int
The (unrecognised) type of swallowed frame
frameTypeId
,
int
The flags set in the header of the swallowed frame
flags
,
int
The payload size of the swallowed frame
size
)

Implements org.apache.coyote.http2.Http2Parser.Output.onSwallowedUnknownFrame.

Notification triggered when the parser swallows the payload of an unknown frame.

public void
public void
public void
protected void
processConnection(WebConnection webConnection, Stream stream)

protected SendfileState

Returns:

The result of the send file processing
processSendfile
(SendfileData
The stream and associated data to process
sendfileData
)

Process send file (if supported) for the given stream.

protected void
pack-priv void
protected void
private void
pruneClosedStreams(int streamId)

pack-priv void
push(Request request, Stream associatedStream)

public void
private void
pack-priv void
private Set<AbstractStream>
releaseBackLog(int increment)

pack-priv void
public void
reprioritise(int
Unused
streamId
,
int
Unused
parentStreamId
,
boolean
Unused
exclusive
,
int
Unused
weight
)
Deprecated Unused. Will be removed in Tomcat 11 onwards.

Unused - NO-OP.

pack-priv int
reserveWindowSize(Stream stream, int reservation, boolean block)

public void
reset(int streamId, long errorCode)

Implements org.apache.coyote.http2.Http2Parser.Output.reset.

pack-priv void
protected void
private void
setConnectionTimeout(long connectionTimeout)

protected void
private void
setMaxProcessedStream(int streamId)

public void
public void
public void
public void
public ByteBuffer
startRequestBodyFrame(int streamId, int payloadSize, boolean endOfStream)

Implements org.apache.coyote.http2.Http2Parser.Output.startRequestBodyFrame.

public void
private void
updateOverheadCount(FrameType frameType, int increment)

public AbstractEndpoint.Handler.SocketState
pack-priv void
writeBody(Stream stream, ByteBuffer data, int len, boolean finished)

protected void
writeGoAwayFrame(int maxStreamId, long errorCode, byte[] debugMsg)

pack-priv void
writeHeaders(Stream stream, int pushedStreamId, MimeHeaders mimeHeaders, boolean endOfStream, int payloadSize)

protected void
writeSettings()

Write the initial settings frame and any necessary supporting frames.

pack-priv void
writeWindowUpdate(AbstractNonZeroStream stream, int increment, boolean applicationInitiated)

Inherited from org.apache.coyote.http2.AbstractStream:
decrementWindowSizegetConnectionAllocationMadegetConnectionAllocationRequestedgetIdAsIntgetIdAsStringgetIdentifiergetWindowSizesetConnectionAllocationMadesetConnectionAllocationRequestedsetWindowSize