cwist
Modern C web framework with libttak runtime
Loading...
Searching...
No Matches
h3_hdr_out.h
Go to the documentation of this file.
1
6
#ifndef CWIST_NET_HTTP_H3_HDR_OUT_H
7
#define CWIST_NET_HTTP_H3_HDR_OUT_H
8
9
#include <lsquic.h>
10
#include <lsxpack_header.h>
11
#include <stdbool.h>
12
#include <stddef.h>
13
#include <string.h>
14
15
/* Outgoing header set under construction for lsquic_stream_send_headers():
16
* each field is copied into buf as the name, two spare bytes, then the value,
17
* and the next lsxpack_header slot points at it. */
18
typedef
struct
{
19
struct
lsxpack_header
*
arr
;
20
size_t
count
, max;
21
char
*
buf
;
22
size_t
off,
cap
;
23
}
h3_hdr_out
;
24
26
static
inline
bool
h3_hdr_out_add(
h3_hdr_out
*h,
const
char
*name,
size_t
nlen
,
const
char
*
val
,
27
size_t
vlen
) {
28
if
(h->
count
>= h->
max
|| h->
off
+
nlen
+ 2 +
vlen
> h->
cap
)
return
false
;
29
memcpy
(h->
buf
+ h->
off
, name,
nlen
);
30
memcpy
(h->
buf
+ h->
off
+
nlen
+ 2,
val
,
vlen
);
31
lsxpack_header_set_offset2
(&h->
arr
[h->
count
], h->
buf
+ h->
off
, 0,
nlen
,
nlen
+ 2,
vlen
);
32
h->
off
+=
nlen
+ 2 +
vlen
;
33
h->
count
++;
34
return
true
;
35
}
36
37
static
inline
bool
h3_hdr_out_add_str(
h3_hdr_out
*h,
const
char
*name,
const
char
*
val
) {
38
return
h3_hdr_out_add(h, name,
strlen
(name),
val
,
strlen
(
val
));
39
}
40
41
#endif
/* CWIST_NET_HTTP_H3_HDR_OUT_H */
cap
size_t cap
Definition
otel.c:56
h3_hdr_out
Definition
h3_hdr_out.h:18
h3_hdr_out::cap
size_t cap
Definition
h3_hdr_out.h:22
h3_hdr_out::count
size_t count
Definition
h3_hdr_out.h:20
h3_hdr_out::max
size_t max
Definition
h3_hdr_out.h:20
h3_hdr_out::buf
char * buf
Definition
h3_hdr_out.h:21
h3_hdr_out::arr
struct lsxpack_header * arr
Definition
h3_hdr_out.h:19
h3_hdr_out::off
size_t off
Definition
h3_hdr_out.h:22
src
net
http
h3_hdr_out.h
Generated by
1.9.8