MIRROR: javascript for 馃悳's, a tiny runtime with big ambitions
1#ifndef HEADERS_H
2#define HEADERS_H
3
4#include "types.h"
5#include "modules/symbol.h"
6
7extern ant_value_t g_headers_iter_proto;
8extern ant_value_t g_headers_proto;
9
10typedef enum {
11 HEADERS_GUARD_NONE = 0,
12 HEADERS_GUARD_REQUEST,
13 HEADERS_GUARD_REQUEST_NO_CORS,
14 HEADERS_GUARD_RESPONSE,
15 HEADERS_GUARD_IMMUTABLE
16} headers_guard_t;
17
18typedef void (*headers_foreach_cb)(
19 const char *name,
20 const char *value,
21 void *ctx
22);
23
24void init_headers_module(void);
25void headers_apply_guard(ant_value_t hdrs);
26void headers_set_guard(ant_value_t hdrs, headers_guard_t guard);
27void headers_append_if_missing(ant_value_t hdrs, const char *name, const char *value);
28void headers_for_each(ant_value_t hdrs, headers_foreach_cb cb, void *ctx);
29
30bool headers_is_headers(ant_value_t obj);
31bool headers_copy_from(ant_t *js, ant_value_t dst, ant_value_t src);
32bool advance_headers(ant_t *js, struct js_iter_t *it, ant_value_t *out);
33bool headers_init_has_name(ant_t *js, ant_value_t init, const char *name);
34bool headers_set_literal(ant_t *js, ant_value_t hdrs, const char *name, const char *value);
35
36ant_value_t headers_create_empty(ant_t *js);
37ant_value_t headers_create_from_init(ant_t *js, ant_value_t init);
38ant_value_t headers_get_value(ant_t *js, ant_value_t hdrs, const char *name);
39ant_value_t headers_append_value(ant_t *js, ant_value_t hdrs, ant_value_t name_v, ant_value_t value_v);
40ant_value_t headers_append_literal(ant_t *js, ant_value_t hdrs, const char *name, const char *value);
41
42headers_guard_t headers_get_guard(ant_value_t hdrs);
43
44#endif