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. */
18typedef struct {
20 size_t count, max;
21 char *buf;
22 size_t off, cap;
24
26static 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
37static 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 */
size_t cap
Definition otel.c:56
size_t cap
Definition h3_hdr_out.h:22
size_t count
Definition h3_hdr_out.h:20
size_t max
Definition h3_hdr_out.h:20
char * buf
Definition h3_hdr_out.h:21
struct lsxpack_header * arr
Definition h3_hdr_out.h:19
size_t off
Definition h3_hdr_out.h:22