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