Sese Framework
x.y.z
A cross-platform framework
载入中...
搜索中...
未找到
Http2Frame.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 <cstdint>
26
#include <memory>
27
28
namespace
sese::net::http
{
29
30
constexpr
static
uint8_t
FRAME_FLAG_END_STREAM
= 0x1;
31
constexpr
static
uint8_t
FRAME_FLAG_END_HEADERS
= 0x4;
32
constexpr
static
uint8_t
FRAME_FLAG_PADDED
= 0x8;
33
constexpr
static
uint8_t
FRAME_FLAG_PRIORITY
= 0x20;
34
35
constexpr
static
uint8_t
FRAME_TYPE_DATA
= 0x0;
36
constexpr
static
uint8_t
FRAME_TYPE_HEADERS
= 0x1;
37
constexpr
static
uint8_t
FRAME_TYPE_PRIORITY
= 0x2;
38
constexpr
static
uint8_t
FRAME_TYPE_RST_STREAM
= 0x3;
39
constexpr
static
uint8_t
FRAME_TYPE_SETTINGS
= 0x4;
40
constexpr
static
uint8_t
FRAME_TYPE_PUSH_PROMISE
= 0x5;
41
constexpr
static
uint8_t
FRAME_TYPE_PING
= 0x6;
42
constexpr
static
uint8_t
FRAME_TYPE_GOAWAY
= 0x7;
43
constexpr
static
uint8_t
FRAME_TYPE_WINDOW_UPDATE
= 0x8;
44
constexpr
static
uint8_t
FRAME_TYPE_CONTINUATION
= 0x9;
45
constexpr
static
uint8_t
FRAME_TYPE_ALTSVC
= 0xa;
46
constexpr
static
uint8_t
FRAME_TYPE_ORIGIN
= 0xc;
47
48
constexpr
static
uint8_t
GOAWAY_NO_ERROR
= 0x0;
49
constexpr
static
uint8_t
GOAWAY_PROTOCOL_ERROR
= 0x1;
50
constexpr
static
uint8_t
GOAWAY_INTERNAL_ERROR
= 0x2;
51
constexpr
static
uint8_t
GOAWAY_FLOW_CONTROL_ERROR
= 0x3;
52
constexpr
static
uint8_t
GOAWAY_SETTINGS_TIMEOUT
= 0x4;
53
constexpr
static
uint8_t
GOAWAY_STREAM_CLOSED
= 0x5;
54
constexpr
static
uint8_t
GOAWAY_FRAME_SIZE_ERROR
= 0x6;
55
constexpr
static
uint8_t
GOAWAY_REFUSED_STREAM
= 0x7;
56
constexpr
static
uint8_t
GOAWAY_CANCEL
= 0x8;
57
constexpr
static
uint8_t
GOAWAY_COMPRESSION_ERROR
= 0x9;
58
constexpr
static
uint8_t
GOAWAY_CONNECT_ERROR
= 0xa;
59
constexpr
static
uint8_t
GOAWAY_ENHANCE_YOUR_CALM
= 0xb;
60
constexpr
static
uint8_t
GOAWAY_INADEQUATE_SECURITY
= 0xc;
61
constexpr
static
uint8_t
GOAWAY_HTTP_1_1_REQUIRED
= 0xd;
62
63
constexpr
static
uint16_t
SETTINGS_HEADER_TABLE_SIZE
= 0x1;
64
constexpr
static
uint16_t
SETTINGS_ENABLE_PUSH
= 0x2;
65
constexpr
static
uint16_t
SETTINGS_MAX_CONCURRENT_STREAMS
= 0x3;
66
constexpr
static
uint16_t
SETTINGS_INITIAL_WINDOW_SIZE
= 0x4;
67
constexpr
static
uint16_t
SETTINGS_MAX_FRAME_SIZE
= 0x5;
68
constexpr
static
uint16_t
SETTINGS_MAX_HEADER_LIST_SIZE
= 0x6;
69
70
constexpr
static
uint8_t
SETTINGS_FLAGS_ACK
= 0x1;
71
72
constexpr
static
auto
MAGIC_STRING
=
"PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"
;
73
75
struct
Http2FrameInfo
{
76
uint32_t
length
;
77
uint8_t
type
;
78
uint8_t
flags
;
79
uint32_t
ident
;
80
};
81
83
struct
Http2Frame
{
84
using
Ptr
= std::unique_ptr<Http2Frame>;
85
86
uint32_t
length
;
87
uint8_t
type
;
88
uint8_t
flags
;
89
uint32_t
ident
;
90
91
std::unique_ptr<char []>
frame
;
92
93
explicit
Http2Frame
(
size_t
frame_size);
94
97
[[nodiscard]]
char
*
getFrameBuffer
()
const
;
98
101
[[nodiscard]]
size_t
getFrameLength
()
const
;
102
105
[[nodiscard]]
char
*
getFrameContentBuffer
()
const
;
106
109
[[nodiscard]]
size_t
getFrameContentLength
()
const
;
110
112
void
buildFrameHeader
()
const
;
113
};
114
115
}
// namespace sese::net::http
sese
net
http
Http2Frame.h
生成于 2024年 十一月 4日 星期一 09:58:01 , 为 Sese Framework使用
1.11.0