PageRenderTime 9ms CodeModel.GetById 2ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 1ms

/http.h

http://github.com/nicolasff/webdis
C++ Header | 75 lines | 49 code | 25 blank | 1 comment | 0 complexity | ab21e2ac0d0ac9ba38fd719e4636cc13 MD5 | raw file
 1#ifndef HTTP_H
 2#define HTTP_H
 3
 4#include <sys/types.h>
 5#include <event.h>
 6
 7struct http_client;
 8struct worker;
 9
10struct http_header {
11	char *key;
12	size_t key_sz;
13
14	char *val;
15	size_t val_sz;
16};
17
18
19struct http_response {
20
21	struct event ev;
22
23	short code;
24	const char *msg;
25
26	struct http_header *headers;
27	int header_count;
28
29	const char *body;
30	size_t body_len;
31
32	char *out;
33	size_t out_sz;
34
35	int chunked;
36	int http_version;
37	int keep_alive;
38	int sent;
39
40	struct worker *w;
41};
42
43/* HTTP response */
44
45struct http_response *
46http_response_init(struct worker *w, int code, const char *msg);
47
48void
49http_response_set_header(struct http_response *r, const char *k, const char *v);
50
51void
52http_response_set_body(struct http_response *r, const char *body, size_t body_len);
53
54void
55http_response_write(struct http_response *r, int fd);
56
57void
58http_schedule_write(int fd, struct http_response *r);
59
60void
61http_crossdomain(struct http_client *c);
62
63void
64http_send_error(struct http_client *c, short code, const char *msg);
65
66void
67http_send_options(struct http_client *c);
68
69void
70http_response_write_chunk(int fd, struct worker *w, const char *p, size_t sz);
71
72void
73http_response_set_keep_alive(struct http_response *r, int enabled);
74
75#endif