MIRROR: javascript for 馃悳's, a tiny runtime with big ambitions
1#ifndef RESPONSE_H
2#define RESPONSE_H
3
4#include <stdbool.h>
5#include <stddef.h>
6#include <stdint.h>
7#include "types.h"
8#include "modules/headers.h"
9#include "modules/url.h"
10
11typedef struct {
12 char *type;
13 url_state_t url;
14 bool has_url;
15 int url_list_size;
16 int status;
17 char *status_text;
18 uint8_t *body_data;
19 size_t body_size;
20 char *body_type;
21 bool body_is_stream;
22 bool has_body;
23 bool body_used;
24} response_data_t;
25
26extern ant_value_t g_response_proto;
27void init_response_module(void);
28
29response_data_t *response_get_data(ant_value_t obj);
30ant_value_t response_get_headers(ant_value_t obj);
31
32ant_value_t response_create(
33 ant_t *js,
34 const char *type,
35 int status,
36 const char *status_text,
37 ant_value_t headers_obj,
38 const uint8_t *body,
39 size_t body_len,
40 const char *body_type,
41 headers_guard_t guard
42);
43
44ant_value_t response_create_fetched(
45 ant_t *js,
46 int status,
47 const char *status_text,
48 const char *url,
49 int url_list_size,
50 ant_value_t headers_obj,
51 const uint8_t *body,
52 size_t body_len,
53 ant_value_t body_stream,
54 const char *body_type
55);
56
57#endif