Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
hpack.h
Go to the documentation of this file.
1
5/*
6 * Copyright (c) 2023 Emna Rekik
7 * Copyright (c) 2024 Nordic Semiconductor ASA
8 *
9 * SPDX-License-Identifier: Apache-2.0
10 */
11
12#ifndef ZEPHYR_INCLUDE_NET_HTTP_SERVER_HPACK_H_
13#define ZEPHYR_INCLUDE_NET_HTTP_SERVER_HPACK_H_
14
15#include <stddef.h>
16#include <stdint.h>
17
25#ifdef __cplusplus
26extern "C" {
27#endif
28
31enum http_hpack_static_key {
32 HTTP_SERVER_HPACK_INVALID = 0,
33 HTTP_SERVER_HPACK_AUTHORITY = 1,
34 HTTP_SERVER_HPACK_METHOD_GET = 2,
35 HTTP_SERVER_HPACK_METHOD_POST = 3,
36 HTTP_SERVER_HPACK_PATH_ROOT = 4,
37 HTTP_SERVER_HPACK_PATH_INDEX = 5,
38 HTTP_SERVER_HPACK_SCHEME_HTTP = 6,
39 HTTP_SERVER_HPACK_SCHEME_HTTPS = 7,
40 HTTP_SERVER_HPACK_STATUS_200 = 8,
41 HTTP_SERVER_HPACK_STATUS_204 = 9,
42 HTTP_SERVER_HPACK_STATUS_206 = 10,
43 HTTP_SERVER_HPACK_STATUS_304 = 11,
44 HTTP_SERVER_HPACK_STATUS_400 = 12,
45 HTTP_SERVER_HPACK_STATUS_404 = 13,
46 HTTP_SERVER_HPACK_STATUS_500 = 14,
47 HTTP_SERVER_HPACK_ACCEPT_CHARSET = 15,
48 HTTP_SERVER_HPACK_ACCEPT_ENCODING = 16,
49 HTTP_SERVER_HPACK_ACCEPT_LANGUAGE = 17,
50 HTTP_SERVER_HPACK_ACCEPT_RANGES = 18,
51 HTTP_SERVER_HPACK_ACCEPT = 19,
52 HTTP_SERVER_HPACK_ACCESS_CONTROL_ALLOW_ORIGIN = 20,
53 HTTP_SERVER_HPACK_AGE = 21,
54 HTTP_SERVER_HPACK_ALLOW = 22,
55 HTTP_SERVER_HPACK_AUTHORIZATION = 23,
56 HTTP_SERVER_HPACK_CACHE_CONTROL = 24,
57 HTTP_SERVER_HPACK_CONTENT_DISPOSITION = 25,
58 HTTP_SERVER_HPACK_CONTENT_ENCODING = 26,
59 HTTP_SERVER_HPACK_CONTENT_LANGUAGE = 27,
60 HTTP_SERVER_HPACK_CONTENT_LENGTH = 28,
61 HTTP_SERVER_HPACK_CONTENT_LOCATION = 29,
62 HTTP_SERVER_HPACK_CONTENT_RANGE = 30,
63 HTTP_SERVER_HPACK_CONTENT_TYPE = 31,
64 HTTP_SERVER_HPACK_COOKIE = 32,
65 HTTP_SERVER_HPACK_DATE = 33,
66 HTTP_SERVER_HPACK_ETAG = 34,
67 HTTP_SERVER_HPACK_EXPECT = 35,
68 HTTP_SERVER_HPACK_EXPIRES = 36,
69 HTTP_SERVER_HPACK_FROM = 37,
70 HTTP_SERVER_HPACK_HOST = 38,
71 HTTP_SERVER_HPACK_IF_MATCH = 39,
72 HTTP_SERVER_HPACK_IF_MODIFIED_SINCE = 40,
73 HTTP_SERVER_HPACK_IF_NONE_MATCH = 41,
74 HTTP_SERVER_HPACK_IF_RANGE = 42,
75 HTTP_SERVER_HPACK_IF_UNMODIFIED_SINCE = 43,
76 HTTP_SERVER_HPACK_LAST_MODIFIED = 44,
77 HTTP_SERVER_HPACK_LINK = 45,
78 HTTP_SERVER_HPACK_LOCATION = 46,
79 HTTP_SERVER_HPACK_MAX_FORWARDS = 47,
80 HTTP_SERVER_HPACK_PROXY_AUTHENTICATE = 48,
81 HTTP_SERVER_HPACK_PROXY_AUTHORIZATION = 49,
82 HTTP_SERVER_HPACK_RANGE = 50,
83 HTTP_SERVER_HPACK_REFERER = 51,
84 HTTP_SERVER_HPACK_REFRESH = 52,
85 HTTP_SERVER_HPACK_RETRY_AFTER = 53,
86 HTTP_SERVER_HPACK_SERVER = 54,
87 HTTP_SERVER_HPACK_SET_COOKIE = 55,
88 HTTP_SERVER_HPACK_STRICT_TRANSPORT_SECURITY = 56,
89 HTTP_SERVER_HPACK_TRANSFER_ENCODING = 57,
90 HTTP_SERVER_HPACK_USER_AGENT = 58,
91 HTTP_SERVER_HPACK_VARY = 59,
92 HTTP_SERVER_HPACK_VIA = 60,
93 HTTP_SERVER_HPACK_WWW_AUTHENTICATE = 61,
94};
95
96/* TODO Kconfig */
97#define HTTP2_HEADER_FIELD_MAX_LEN 256
98
99#if defined(CONFIG_HTTP_SERVER)
100#define HTTP_SERVER_HUFFMAN_DECODE_BUFFER_SIZE CONFIG_HTTP_SERVER_HUFFMAN_DECODE_BUFFER_SIZE
101#else
102#define HTTP_SERVER_HUFFMAN_DECODE_BUFFER_SIZE 0
103#endif
104
110 const char *name;
111
113 const char *value;
114
116 size_t name_len;
117
119 size_t value_len;
120
122 uint8_t buf[HTTP_SERVER_HUFFMAN_DECODE_BUFFER_SIZE];
123
125 size_t datalen;
126};
127
130int http_hpack_huffman_decode(const uint8_t *encoded_buf, size_t encoded_len,
131 uint8_t *buf, size_t buflen);
132int http_hpack_huffman_encode(const uint8_t *str, size_t str_len,
133 uint8_t *buf, size_t buflen);
134int http_hpack_decode_header(const uint8_t *buf, size_t datalen,
135 struct http_hpack_header_buf *header);
136int http_hpack_encode_header(uint8_t *buf, size_t buflen,
137 struct http_hpack_header_buf *header);
138
141#ifdef __cplusplus
142}
143#endif
144
149#endif
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
HTTP2 header field with decoding buffer.
Definition hpack.h:108
size_t value_len
Length of the decoded header field value.
Definition hpack.h:119
uint8_t buf[HTTP_SERVER_HUFFMAN_DECODE_BUFFER_SIZE]
Encoding/Decoding buffer.
Definition hpack.h:122
const char * value
A pointer to the decoded header field value.
Definition hpack.h:113
size_t datalen
Length of the data in the decoding buffer.
Definition hpack.h:125
const char * name
A pointer to the decoded header field name.
Definition hpack.h:110
size_t name_len
Length of the decoded header field name.
Definition hpack.h:116