Sese Framework
2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
HPackUtil.h
Go to the documentation of this file.
1
// Copyright 2024 libsese
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
23
#pragma once
24
25
#include "
sese/io/InputStream.h
"
26
#include "
sese/io/OutputStream.h
"
27
#include "
sese/util/NotInstantiable.h
"
28
#include "
sese/net/http/Header.h
"
29
#include "
sese/net/http/DynamicTable.h
"
30
#include "
sese/net/http/Huffman.h
"
31
32
namespace
sese::net::http
{
33
35
class
HPackUtil
final :
public
NotInstantiable
{
36
public
:
37
using
InputStream
=
io::InputStream
;
38
using
OutputStream
=
io::OutputStream
;
39
40
HPackUtil
() =
delete
;
41
51
static
uint32_t
decode
(
52
InputStream
*src,
53
size_t
content_length,
54
DynamicTable
&table,
55
Header
&header,
56
bool
is_resp,
57
bool
has_pseudo =
true
,
58
uint32_t limit = 8192
59
) noexcept;
60
67
static
size_t
encode
(
OutputStream
*dest,
DynamicTable
&table,
Header
&once_header,
Header
&indexed_header) noexcept;
68
69
private:
70
static
int
decodeInteger
(uint8_t &buf,
InputStream
*src, uint32_t &dest, uint8_t n) noexcept;
71
72
static
int
decodeString
(
InputStream
*src, std::
string
&dest) noexcept;
73
74
static
size_t
encodeIndexCase0
(
OutputStream
*dest,
size_t
index) noexcept;
75
76
static
size_t
encodeIndexCase1
(
OutputStream
*dest,
size_t
index) noexcept;
77
78
static
size_t
encodeIndexCase2
(
OutputStream
*dest,
size_t
index) noexcept;
79
80
static
size_t
encodeIndexCase3
(
OutputStream
*dest,
size_t
index) noexcept;
81
82
static
size_t
encodeString
(
OutputStream
*dest, const std::
string
&str) noexcept;
83
84
static std::
string
buildCookieString
(const
Cookie
::Ptr &cookie) noexcept;
85
92
static
bool
setHeader
(
Header
&header, const std::
string
&key, const std::
string
&value) noexcept;
93
98
static
bool
verifyHeader
(
Header
&header,
bool
is_resp) noexcept;
99
100
static const std::
string
REQ_PSEUDO_HEADER
[4];
101
102
static
HuffmanDecoder
decoder
;
103
static
HuffmanEncoder
encoder
;
104
};
105
}
// namespace sese::net::http
sese
net
http
HPackUtil.h
Generated on Tue Jan 7 2025 15:49:06 for Sese Framework by
1.11.0