Sese Framework
x.y.z
A cross-platform framework
载入中...
搜索中...
未找到
HPackUtil.h
浏览该文件的文档.
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
:
38
using
InputStream
=
io::InputStream
;
40
using
OutputStream
=
io::OutputStream
;
41
42
HPackUtil
() =
delete
;
43
53
static
uint32_t
decode
(
54
InputStream
*src,
55
size_t
content_length,
56
DynamicTable
&table,
57
Header
&header,
58
bool
is_resp,
59
bool
has_pseudo =
true
,
60
uint32_t limit = 8192
61
) noexcept;
62
69
static
size_t
encode
(
OutputStream
*dest,
DynamicTable
&table,
Header
&once_header,
Header
&indexed_header) noexcept;
70
71
private:
72
static
int
decodeInteger
(uint8_t &buf,
InputStream
*src, uint32_t &dest, uint8_t n) noexcept;
73
74
static
int
decodeString
(
InputStream
*src, std::
string
&dest) noexcept;
75
76
static
size_t
encodeIndexCase0
(
OutputStream
*dest,
size_t
index) noexcept;
77
78
static
size_t
encodeIndexCase1
(
OutputStream
*dest,
size_t
index) noexcept;
79
80
static
size_t
encodeIndexCase2
(
OutputStream
*dest,
size_t
index) noexcept;
81
82
static
size_t
encodeIndexCase3
(
OutputStream
*dest,
size_t
index) noexcept;
83
84
static
size_t
encodeString
(
OutputStream
*dest, const std::
string
&str) noexcept;
85
86
static std::
string
buildCookieString
(const
Cookie
::Ptr &cookie) noexcept;
87
94
static
bool
setHeader
(
Header
&header, const std::
string
&key, const std::
string
&value) noexcept;
95
100
static
bool
verifyHeader
(
Header
&header,
bool
is_resp) noexcept;
101
102
static const std::
string
REQ_PSEUDO_HEADER
[4];
103
104
static
HuffmanDecoder
decoder
;
105
static
HuffmanEncoder
encoder
;
106
};
107
}
// namespace sese::net::http
sese
net
http
HPackUtil.h
生成于 2024年 十一月 4日 星期一 09:58:01 , 为 Sese Framework使用
1.11.0