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

public Class HpackDecoder

extends Object
Class Inheritance
Static Imports
io.undertow.protocols.http2.Hpack.HeaderField

A decoder for HPACK.
Author
Stuart Douglas

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface

Field Summary

Modifier and TypeField and Description
private int
currentMemorySize

the current calculates memory size, as per the HPACK algorithm

private static final int
private int
filledTableSlots

The current table size by index (aka the number of index positions that are filled up)

private boolean
private int
firstSlotPosition

The current HEAD position of the header table.

private HpackDecoder.HeaderEmitter
headerEmitter

The object that receives the headers that are emitted from this decoder

private Hpack.HeaderField[]
headerTable

The header table

private final int
maxAllowedMemorySize

The maximum allowed memory size, as specified by us.

private int
specifiedMemorySize

The current memory size, as specified by the client

private final StringBuilder

Constructor Summary

AccessConstructor and Description
public
HpackDecoder(int maxAllowedMemorySize)

public

Method Summary

Modifier and TypeMethod and Description
private void
private void
public void
decode(ByteBuffer
The buffer
buffer
,
boolean moreData)

Decodes the provided frame data.

pack-priv int
pack-priv int
pack-priv int
public HpackDecoder.HeaderEmitter
pack-priv Hpack.HeaderField[]
pack-priv int

Returns:

the real index into the array
getRealIndex
(int
The index from the hpack
index
)

because we use a ring buffer type construct, and don't actually shuffle items in the array, we need to figure out he real index to use.

pack-priv int
private void
handleIndex(int
The index
index
)

Handle an indexed header representation

private HttpString
private boolean
handleMaxMemorySizeChange(ByteBuffer buffer, int originalPos)

private HttpString
readHeaderName(ByteBuffer buffer, int prefixLength)

private String
private String
readHuffmanString(int length, ByteBuffer buffer)

private void
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currentMemorySizeback to summary
private int currentMemorySize

the current calculates memory size, as per the HPACK algorithm

DEFAULT_RING_BUFFER_SIZEback to summary
private static final int DEFAULT_RING_BUFFER_SIZE
filledTableSlotsback to summary
private int filledTableSlots

The current table size by index (aka the number of index positions that are filled up)

firstback to summary
private boolean first
firstSlotPositionback to summary
private int firstSlotPosition

The current HEAD position of the header table. We use a ring buffer type construct as it would be silly to actually shuffle the items around in the array.

headerEmitterback to summary
private HpackDecoder.HeaderEmitter headerEmitter

The object that receives the headers that are emitted from this decoder

headerTableback to summary
private Hpack.HeaderField[] headerTable

The header table

maxAllowedMemorySizeback to summary
private final int maxAllowedMemorySize

The maximum allowed memory size, as specified by us. If the client tries to increase beyond this amount it is an error

specifiedMemorySizeback to summary
private int specifiedMemorySize

The current memory size, as specified by the client

stringBuilderback to summary
private final StringBuilder stringBuilder

Constructor Detail

HpackDecoderback to summary
public HpackDecoder(int maxAllowedMemorySize)
HpackDecoderback to summary
public HpackDecoder()

Method Detail

addEntryToHeaderTableback to summary
private void addEntryToHeaderTable(Hpack.HeaderField entry)
addStaticTableEntryback to summary
private void addStaticTableEntry(int index) throws HpackException
decodeback to summary
public void decode(ByteBuffer buffer, boolean moreData) throws HpackException

Decodes the provided frame data. If this method leaves data in the buffer then this buffer should be compacted so this data is preserved, unless there is no more data in which case this should be considered a protocol error.

Parameters
buffer:ByteBuffer

The buffer

getCurrentMemorySizeback to summary
pack-priv int getCurrentMemorySize()
getFilledTableSlotsback to summary
pack-priv int getFilledTableSlots()
getFirstSlotPositionback to summary
pack-priv int getFirstSlotPosition()
getHeaderEmitterback to summary
public HpackDecoder.HeaderEmitter getHeaderEmitter()
getHeaderTableback to summary
pack-priv Hpack.HeaderField[] getHeaderTable()
getRealIndexback to summary
pack-priv int getRealIndex(int index) throws HpackException

because we use a ring buffer type construct, and don't actually shuffle items in the array, we need to figure out he real index to use.

package private for unit tests

Parameters
index:int

The index from the hpack

Returns:int

the real index into the array

getSpecifiedMemorySizeback to summary
pack-priv int getSpecifiedMemorySize()
handleIndexback to summary
private void handleIndex(int index) throws HpackException

Handle an indexed header representation

Parameters
index:int

The index

handleIndexedHeaderNameback to summary
private HttpString handleIndexedHeaderName(int index) throws HpackException
handleMaxMemorySizeChangeback to summary
private boolean handleMaxMemorySizeChange(ByteBuffer buffer, int originalPos) throws HpackException
readHeaderNameback to summary
private HttpString readHeaderName(ByteBuffer buffer, int prefixLength) throws HpackException
readHpackStringback to summary
private String readHpackString(ByteBuffer buffer) throws HpackException
readHuffmanStringback to summary
private String readHuffmanString(int length, ByteBuffer buffer) throws HpackException
resizeIfRequiredback to summary
private void resizeIfRequired()
setHeaderEmitterback to summary
public void setHeaderEmitter(HpackDecoder.HeaderEmitter headerEmitter)
io.undertow.protocols.http2 back to summary

public Interface HpackDecoder.HeaderEmitter

Known Direct Implementers
io.undertow.protocols.http2.Http2HeaderBlockParser

Method Summary

Modifier and TypeMethod and Description
public void
emitHeader(HttpString name, String value, boolean neverIndex)

Method Detail

emitHeaderback to summary
public void emitHeader(HttpString name, String value, boolean neverIndex) throws HpackException