public abstract class Http2Connection extends Object
Modifier and Type | Class and Description |
---|---|
class |
Http2Connection.PushStreamBuilder |
class |
Http2Connection.RegularStreamBuilder |
class |
Http2Connection.StreamBuilder |
Modifier and Type | Field and Description |
---|---|
protected List<Http2Frame> |
tmpHeaderFramesList |
Constructor and Description |
---|
Http2Connection(Connection<?> connection,
boolean isServer,
Http2BaseFilter handlerFilter) |
Modifier and Type | Method and Description |
---|---|
Http2Stream |
acceptUpgradeStream(HttpRequestPacket request,
int priority,
boolean fin)
The method is called to create an
Http2Stream initiated via
HTTP/1.1 Upgrade mechanism. |
protected void |
checkFrameSequenceSemantics(Http2Frame frame) |
protected List<Http2Frame> |
encodeHttpHeaderAsHeaderFrames(FilterChainContext ctx,
HttpHeader httpHeader,
int streamId,
boolean isLast,
List<Http2Frame> toList)
Encodes the
HttpHeader and locks the compression lock. |
protected List<Http2Frame> |
encodeHttpRequestAsPushPromiseFrames(FilterChainContext ctx,
HttpRequestPacket httpRequest,
int streamId,
int promisedStreamId,
List<Http2Frame> toList)
Encodes the
HttpRequestPacket as a PushPromiseFrame
and locks the compression lock. |
static Http2Connection |
get(Connection connection) |
int |
getAvailablePeerConnectionWindowSize() |
Connection |
getConnection() |
abstract int |
getDefaultConnectionWindowSize() |
abstract int |
getDefaultMaxConcurrentStreams() |
abstract int |
getDefaultStreamWindowSize() |
abstract int |
getFrameHeaderSize() |
protected abstract int |
getFrameSize(Buffer buffer)
Returns the total frame size (including header size), or -1
if the buffer doesn't contain enough bytes to read the size.
|
int |
getLocalConnectionWindowSize() |
int |
getLocalMaxConcurrentStreams() |
int |
getLocalMaxFramePayloadSize() |
int |
getLocalStreamWindowSize() |
MemoryManager |
getMemoryManager() |
ReentrantLock |
getNewClientStreamLock()
The
ReentrantLock , which assures that requests assigned to newly
allocated stream IDs will be sent to the server in their order. |
int |
getNextLocalStreamId() |
protected Http2ConnectionOutputSink |
getOutputSink() |
int |
getPeerMaxConcurrentStreams() |
int |
getPeerMaxFramePayloadSize() |
int |
getPeerStreamWindowSize() |
protected abstract int |
getSpecDefaultFramePayloadSize() |
protected abstract int |
getSpecMaxFramePayloadSize() |
protected abstract int |
getSpecMinFramePayloadSize() |
Http2Stream |
getStream(int streamId) |
Http2Connection.StreamBuilder |
getStreamBuilder() |
abstract DraftVersion |
getVersion() |
void |
goAway(ErrorCode errorCode)
If the session is still open - closes it and sends GOAWAY frame to a peer,
otherwise if the session was already closed - does nothing.
|
protected abstract boolean |
isFrameReady(Buffer buffer) |
boolean |
isLocallyInitiatedStream(int streamId) |
boolean |
isServer() |
protected abstract Http2ConnectionOutputSink |
newOutputSink() |
protected Http2Stream |
newStream(HttpRequestPacket request,
int streamId,
int refStreamId,
int priority,
Http2StreamState initialState) |
protected Http2Stream |
newUpgradeStream(HttpRequestPacket request,
int priority,
Http2StreamState initialState) |
protected void |
onOversizedFrame(Buffer buffer) |
Http2Stream |
openStream(HttpRequestPacket request,
int streamId,
int refStreamId,
int priority,
Http2StreamState initState)
Method is not thread-safe, it is expected that it will be called
within
getNewClientStreamLock() lock scope. |
Http2Stream |
openUpgradeStream(HttpRequestPacket request,
int priority)
The method is called on the client side, when the server confirms
HTTP/1.1 -> HTTP/2.0 upgrade with '101' response.
|
abstract Http2Frame |
parseHttp2FrameHeader(Buffer buffer) |
protected SettingsFrame.SettingsFrameBuilder |
prepareSettings() |
protected SettingsFrame.SettingsFrameBuilder |
prepareSettings(SettingsFrame.SettingsFrameBuilder builder) |
protected void |
sendClientPreface() |
protected void |
sendRstFrame(ErrorCode errorCode,
int streamId) |
protected void |
sendServerPreface() |
protected void |
sendWindowUpdate(int streamId,
int delta) |
abstract void |
serializeHttp2FrameHeader(Http2Frame frame,
Buffer buffer) |
void |
setLocalConnectionWindowSize(int localConnectionWindowSize) |
void |
setLocalMaxConcurrentStreams(int localMaxConcurrentStreams)
Sets the default maximum number of concurrent streams allowed for this session by our side.
|
void |
setLocalStreamWindowSize(int localStreamWindowSize) |
protected void |
setPeerMaxFramePayloadSize(int peerMaxFramePayloadSize)
Sets the max payload size to be accepted by the peer.
|
protected final List<Http2Frame> tmpHeaderFramesList
public Http2Connection(Connection<?> connection, boolean isServer, Http2BaseFilter handlerFilter)
public static Http2Connection get(Connection connection)
public abstract DraftVersion getVersion()
protected abstract Http2ConnectionOutputSink newOutputSink()
protected abstract int getSpecDefaultFramePayloadSize()
protected abstract int getSpecMinFramePayloadSize()
protected abstract int getSpecMaxFramePayloadSize()
public abstract int getFrameHeaderSize()
public abstract void serializeHttp2FrameHeader(Http2Frame frame, Buffer buffer)
public abstract Http2Frame parseHttp2FrameHeader(Buffer buffer) throws Http2ConnectionException
Http2ConnectionException
public abstract int getDefaultConnectionWindowSize()
public abstract int getDefaultStreamWindowSize()
public abstract int getDefaultMaxConcurrentStreams()
protected abstract boolean isFrameReady(Buffer buffer)
protected abstract int getFrameSize(Buffer buffer)
buffer
- protected Http2Stream newStream(HttpRequestPacket request, int streamId, int refStreamId, int priority, Http2StreamState initialState)
protected Http2Stream newUpgradeStream(HttpRequestPacket request, int priority, Http2StreamState initialState)
protected void checkFrameSequenceSemantics(Http2Frame frame) throws Http2ConnectionException
Http2ConnectionException
protected void onOversizedFrame(Buffer buffer) throws Http2ConnectionException
Http2ConnectionException
public final int getLocalMaxFramePayloadSize()
public int getPeerMaxFramePayloadSize()
protected void setPeerMaxFramePayloadSize(int peerMaxFramePayloadSize) throws Http2ConnectionException
SettingsFrame
processing.peerMaxFramePayloadSize
- Http2ConnectionException
- if the peerMaxFramePayloadSize violates the limitspublic int getLocalStreamWindowSize()
public void setLocalStreamWindowSize(int localStreamWindowSize)
public int getPeerStreamWindowSize()
public int getLocalConnectionWindowSize()
public void setLocalConnectionWindowSize(int localConnectionWindowSize)
public int getAvailablePeerConnectionWindowSize()
public int getLocalMaxConcurrentStreams()
public void setLocalMaxConcurrentStreams(int localMaxConcurrentStreams)
localMaxConcurrentStreams
- public int getPeerMaxConcurrentStreams()
public int getNextLocalStreamId()
public Http2Connection.StreamBuilder getStreamBuilder()
public Connection getConnection()
public MemoryManager getMemoryManager()
public boolean isServer()
public boolean isLocallyInitiatedStream(int streamId)
public Http2Stream getStream(int streamId)
protected Http2ConnectionOutputSink getOutputSink()
public void goAway(ErrorCode errorCode)
errorCode
- GOAWAY status code.protected void sendWindowUpdate(int streamId, int delta)
protected void sendServerPreface()
protected void sendClientPreface()
protected void sendRstFrame(ErrorCode errorCode, int streamId)
protected List<Http2Frame> encodeHttpHeaderAsHeaderFrames(FilterChainContext ctx, HttpHeader httpHeader, int streamId, boolean isLast, List<Http2Frame> toList) throws IOException
HttpHeader
and locks the compression lock.ctx
- httpHeader
- streamId
- isLast
- toList
- the target List
, to which the frames will be serializedIOException
protected List<Http2Frame> encodeHttpRequestAsPushPromiseFrames(FilterChainContext ctx, HttpRequestPacket httpRequest, int streamId, int promisedStreamId, List<Http2Frame> toList) throws IOException
HttpRequestPacket
as a PushPromiseFrame
and locks the compression lock.ctx
- httpRequest
- streamId
- promisedStreamId
- toList
- the target List
, to which the frames will be serializedIOException
public ReentrantLock getNewClientStreamLock()
ReentrantLock
, which assures that requests assigned to newly
allocated stream IDs will be sent to the server in their order.
So that request associated with the stream ID '5' won't be sent before
the request associated with the stream ID '3' etc.ReentrantLock
public Http2Stream openStream(HttpRequestPacket request, int streamId, int refStreamId, int priority, Http2StreamState initState) throws Http2StreamException
getNewClientStreamLock()
lock scope.
The caller code is responsible for obtaining and releasing the mentioned
getNewClientStreamLock()
lock.request
- streamId
- refStreamId
- priority
- initState
- Http2StreamException
public Http2Stream acceptUpgradeStream(HttpRequestPacket request, int priority, boolean fin) throws Http2StreamException
Http2Stream
initiated via
HTTP/1.1 Upgrade mechanism.request
- priority
- fin
- Http2StreamException
public Http2Stream openUpgradeStream(HttpRequestPacket request, int priority) throws Http2StreamException
request
- priority
- Http2StreamException
protected SettingsFrame.SettingsFrameBuilder prepareSettings()
protected SettingsFrame.SettingsFrameBuilder prepareSettings(SettingsFrame.SettingsFrameBuilder builder)
Copyright © 2017 Oracle Corporation. All rights reserved.