APIdia Launch Partner
Top Description Inners Fields Constructors Methods
jdk.internal.net.http.frame

public Class FramesDecoder

extends Object
Class Inheritance
Imports
java.io.IOException, java.nio.ByteBuffer, java.nio.charset.StandardCharsets, java.util.ArrayDeque, .ArrayList, .List, .Optional, jdk.internal.net.http.common.Log, .Logger, .Utils

Frames Decoder

collect buffers until frame decoding is possible, all decoded frames are passed to the FrameProcessor callback in order of decoding. It's a stateful class due to the fact that FramesDecoder stores buffers inside. Should be allocated only the single instance per connection.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface

Field Summary

Modifier and TypeField and Description
private boolean
private static final int
COPY_THRESHOLD

Threshold beyond which data is no longer copied into the current buffer, if that buffer has enough unused space.

private ByteBuffer
pack-priv static final Logger
private int
private boolean
private int
private final FramesDecoder.FrameProcessor
private int
private int
private final int
private final List<ByteBuffer>
private boolean
private final ArrayDeque<ByteBuffer>
private int

Constructor Summary

AccessConstructor and Description
public
FramesDecoder(FramesDecoder.FrameProcessor
- callback for decoded frames
frameProcessor
)

Creates Frame Decoder

public
FramesDecoder(FramesDecoder.FrameProcessor
- callback for decoded frames
frameProcessor
,
int
- maxFrameSize accepted by this decoder
maxFrameSize
)

Creates Frame Decoder

Method Summary

Modifier and TypeMethod and Description
public void
public void
decode(ByteBuffer inBoundBuffer)

Adds the data from the given buffer, and performs frame decoding if possible.

private void
private List<ByteBuffer>
getBuffers(boolean isDataFrame, int bytecount)

public int
public byte[]
getBytes(int n)

public int
public int
pack-priv static boolean
isUSAscii(byte[] bytes)

private void
private Http2Frame
private Http2Frame
parseAltSvcFrame(int frameLength, int frameStreamid, int frameFlags)

private Http2Frame
parseContinuationFrame(int frameLength, int streamid, int flags)

private Http2Frame
parseDataFrame(int frameLength, int streamid, int flags)

private Http2Frame
private void
private Http2Frame
parseGoAwayFrame(int frameLength, int streamid, int flags)

private Http2Frame
parseHeadersFrame(int frameLength, int streamid, int flags)

private Http2Frame
parsePingFrame(int frameLength, int streamid, int flags)

private Http2Frame
parsePriorityFrame(int frameLength, int streamid, int flags)

private Http2Frame
parsePushPromiseFrame(int frameLength, int streamid, int flags)

private Http2Frame
parseResetFrame(int frameLength, int streamid, int flags)

private Http2Frame
parseSettingsFrame(int frameLength, int streamid, int flags)

private Http2Frame
parseWindowUpdateFrame(int frameLength, int streamid, int flags)

public void
skipBytes(int bytecount)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

closedback to summary
private boolean closed
COPY_THRESHOLDback to summary
private static final int COPY_THRESHOLD

Threshold beyond which data is no longer copied into the current buffer, if that buffer has enough unused space.

currentBufferback to summary
private ByteBuffer currentBuffer
debugback to summary
pack-priv static final Logger debug
frameFlagsback to summary
private int frameFlags
frameHeaderParsedback to summary
private boolean frameHeaderParsed
frameLengthback to summary
private int frameLength
frameProcessorback to summary
private final FramesDecoder.FrameProcessor frameProcessor
frameStreamidback to summary
private int frameStreamid
frameTypeback to summary
private int frameType
maxFrameSizeback to summary
private final int maxFrameSize
prepareToReleaseback to summary
private final List<ByteBuffer> prepareToRelease
slicedToDataFrameback to summary
private boolean slicedToDataFrame
tailBuffersback to summary
private final ArrayDeque<ByteBuffer> tailBuffers
tailSizeback to summary
private int tailSize

Constructor Detail

FramesDecoderback to summary
public FramesDecoder(FramesDecoder.FrameProcessor frameProcessor)

Creates Frame Decoder

Parameters
frameProcessor:FramesDecoder.FrameProcessor

- callback for decoded frames

FramesDecoderback to summary
public FramesDecoder(FramesDecoder.FrameProcessor frameProcessor, int maxFrameSize)

Creates Frame Decoder

Parameters
frameProcessor:FramesDecoder.FrameProcessor

- callback for decoded frames

maxFrameSize:int

- maxFrameSize accepted by this decoder

Method Detail

closeback to summary
public void close(String msg)
decodeback to summary
public void decode(ByteBuffer inBoundBuffer) throws IOException

Adds the data from the given buffer, and performs frame decoding if possible. Either 1) appends the data from the given buffer to the current buffer ( if there is enough unused space ), or 2) adds it to the next buffer in the queue. If there is enough data to perform frame decoding then, all buffers are decoded and the FrameProcessor is invoked.

frameProcessedback to summary
private void frameProcessed()
getBuffersback to summary
private List<ByteBuffer> getBuffers(boolean isDataFrame, int bytecount)
getByteback to summary
public int getByte()
getBytesback to summary
public byte[] getBytes(int n)
getIntback to summary
public int getInt()
getShortback to summary
public int getShort()
isUSAsciiback to summary
pack-priv static boolean isUSAscii(byte[] bytes)
nextBufferback to summary
private void nextBuffer()
nextFrameback to summary
private Http2Frame nextFrame() throws IOException
parseAltSvcFrameback to summary
private Http2Frame parseAltSvcFrame(int frameLength, int frameStreamid, int frameFlags)
parseContinuationFrameback to summary
private Http2Frame parseContinuationFrame(int frameLength, int streamid, int flags)
parseDataFrameback to summary
private Http2Frame parseDataFrame(int frameLength, int streamid, int flags)
parseFrameBodyback to summary
private Http2Frame parseFrameBody() throws IOException
parseFrameHeaderback to summary
private void parseFrameHeader() throws IOException
parseGoAwayFrameback to summary
private Http2Frame parseGoAwayFrame(int frameLength, int streamid, int flags)
parseHeadersFrameback to summary
private Http2Frame parseHeadersFrame(int frameLength, int streamid, int flags)
parsePingFrameback to summary
private Http2Frame parsePingFrame(int frameLength, int streamid, int flags)
parsePriorityFrameback to summary
private Http2Frame parsePriorityFrame(int frameLength, int streamid, int flags)
parsePushPromiseFrameback to summary
private Http2Frame parsePushPromiseFrame(int frameLength, int streamid, int flags)
parseResetFrameback to summary
private Http2Frame parseResetFrame(int frameLength, int streamid, int flags)
parseSettingsFrameback to summary
private Http2Frame parseSettingsFrame(int frameLength, int streamid, int flags)
parseWindowUpdateFrameback to summary
private Http2Frame parseWindowUpdateFrame(int frameLength, int streamid, int flags)
skipBytesback to summary
public void skipBytes(int bytecount)
jdk.internal.net.http.frame back to summary

public Interface FramesDecoder.FrameProcessor

Annotations
@FunctionalInterface

Method Summary

Modifier and TypeMethod and Description
public void

Method Detail

processFrameback to summary
public void processFrame(Http2Frame frame) throws IOException