Sese Framework  2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
sese::net::http::HPackUtil Class Referencefinal

HPACK decompression tool class. More...

#include <HPackUtil.h>

Inheritance diagram for sese::net::http::HPackUtil:
sese::NotInstantiable

Public Types

using InputStream = io::InputStream
 
using OutputStream = io::OutputStream
 

Public Member Functions

 HPackUtil ()=delete
 
- Public Member Functions inherited from sese::NotInstantiable
 NotInstantiable ()=delete
 
virtual ~NotInstantiable ()=default
 
 NotInstantiable (const NotInstantiable &)=delete
 
NotInstantiableoperator= (const NotInstantiable &)=delete
 

Static Public Member Functions

static uint32_t decode (InputStream *src, size_t content_length, DynamicTable &table, Header &header, bool is_resp, bool has_pseudo=true, uint32_t limit=8192) noexcept
 
static size_t encode (OutputStream *dest, DynamicTable &table, Header &once_header, Header &indexed_header) noexcept
 

Static Private Member Functions

static int decodeInteger (uint8_t &buf, InputStream *src, uint32_t &dest, uint8_t n) noexcept
 
static int decodeString (InputStream *src, std::string &dest) noexcept
 
static size_t encodeIndexCase0 (OutputStream *dest, size_t index) noexcept
 
static size_t encodeIndexCase1 (OutputStream *dest, size_t index) noexcept
 
static size_t encodeIndexCase2 (OutputStream *dest, size_t index) noexcept
 
static size_t encodeIndexCase3 (OutputStream *dest, size_t index) noexcept
 
static size_t encodeString (OutputStream *dest, const std::string &str) noexcept
 
static std::string buildCookieString (const Cookie::Ptr &cookie) noexcept
 
static bool setHeader (Header &header, const std::string &key, const std::string &value) noexcept
 
static bool verifyHeader (Header &header, bool is_resp) noexcept
 

Static Private Attributes

static const std::string REQ_PSEUDO_HEADER [4] {":method", ":scheme", ":authority", ":path"}
 
static HuffmanDecoder decoder {}
 
static HuffmanEncoder encoder {}
 

Detailed Description

HPACK decompression tool class.

Member Typedef Documentation

◆ InputStream

◆ OutputStream

Constructor & Destructor Documentation

◆ HPackUtil()

sese::net::http::HPackUtil::HPackUtil ( )
delete

Member Function Documentation

◆ buildCookieString()

std::string HPackUtil::buildCookieString ( const Cookie::Ptr & cookie)
staticprivatenoexcept

◆ decode()

uint32_t HPackUtil::decode ( InputStream * src,
size_t content_length,
DynamicTable & table,
Header & header,
bool is_resp,
bool has_pseudo = true,
uint32_t limit = 8192 )
staticnoexcept

Attempt to parse HPACK compressed HEADERS from the stream

Parameters
srcStream source
content_lengthLength of content to be parsed
tableDynamic table used for parsing
headerStorage for parsing results
is_respIndicates if this is a response
has_pseudoNeed to verify pseudo-fields at the beginning
limitDynamic table size limit
Returns
Returns 0 if parsing is successful, otherwise returns an error code

Corresponds to case 0

Corresponding to case 1

Corresponding to the 2nd and 3rd cases

References sese::net::http::GOAWAY_COMPRESSION_ERROR, sese::net::http::GOAWAY_PROTOCOL_ERROR, sese::net::http::HttpUtil::parseFromCookie(), and sese::strcmpDoNotCase().

◆ decodeInteger()

int HPackUtil::decodeInteger ( uint8_t & buf,
InputStream * src,
uint32_t & dest,
uint8_t n )
staticprivatenoexcept

◆ decodeString()

int HPackUtil::decodeString ( InputStream * src,
std::string & dest )
staticprivatenoexcept

◆ encode()

size_t HPackUtil::encode ( OutputStream * dest,
DynamicTable & table,
Header & once_header,
Header & indexed_header )
staticnoexcept

Attempt to compress HEADERS in HPACK format

Parameters
destDestination stream
tableDynamic table used for compression
once_headerNon-indexed fields
indexed_headerIndexed fields
Returns
Size of the buffer generated by compression

Corresponds to case 0

Corresponding to case 1

Add a dynamic table

Corresponds to case 0

Corresponding to case 1

Add a dynamic table

Add a dynamic table

Case 0

Case 2

Case 0

Case 2

Cookies are not compressed here

References sese::net::http::PREDEFINED_HEADERS.

◆ encodeIndexCase0()

size_t HPackUtil::encodeIndexCase0 ( OutputStream * dest,
size_t index )
staticprivatenoexcept

◆ encodeIndexCase1()

size_t HPackUtil::encodeIndexCase1 ( OutputStream * dest,
size_t index )
staticprivatenoexcept

◆ encodeIndexCase2()

size_t HPackUtil::encodeIndexCase2 ( OutputStream * dest,
size_t index )
staticprivatenoexcept

◆ encodeIndexCase3()

size_t HPackUtil::encodeIndexCase3 ( OutputStream * dest,
size_t index )
staticprivatenoexcept

◆ encodeString()

size_t HPackUtil::encodeString ( OutputStream * dest,
const std::string & str )
staticprivatenoexcept

Huffman compression is required

Huffman compression is not required

◆ setHeader()

bool HPackUtil::setHeader ( Header & header,
const std::string & key,
const std::string & value )
staticprivatenoexcept

Check for duplicate pseudo-fields and set header values

See also
sese::net::http::HttpConverter
Parameters
headerTarget header
keyKey
valueValue
Returns
Whether setting was successful

◆ verifyHeader()

bool HPackUtil::verifyHeader ( Header & header,
bool is_resp )
staticprivatenoexcept

Validate pseudo-fields

Parameters
headerHeader
is_respWhether it is a response
Returns
Validation result

Member Data Documentation

◆ decoder

HuffmanDecoder HPackUtil::decoder {}
staticprivate

◆ encoder

HuffmanEncoder HPackUtil::encoder {}
staticprivate

◆ REQ_PSEUDO_HEADER

const std::string HPackUtil::REQ_PSEUDO_HEADER {":method", ":scheme", ":authority", ":path"}
staticprivate

The documentation for this class was generated from the following files: