You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
575 B
C
39 lines
575 B
C
#ifndef HTTP_H
|
|
#define HTTP_H
|
|
|
|
#include <sys/types.h>
|
|
|
|
typedef struct {
|
|
char *s;
|
|
size_t sz;
|
|
} str_t;
|
|
|
|
struct http_response {
|
|
short code;
|
|
const char *msg;
|
|
|
|
str_t *headers;
|
|
int header_count;
|
|
|
|
const char *body;
|
|
size_t body_len;
|
|
|
|
int chunked;
|
|
};
|
|
|
|
void
|
|
http_set_header(str_t *h, const char *p, size_t sz);
|
|
|
|
/* HTTP response */
|
|
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);
|
|
|
|
int
|
|
http_response_write(struct http_response *r, int fd);
|
|
|
|
|
|
#endif
|