simple webserver (PoC)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

44 lines
914 B

#ifndef _HTTP_H_
#define _HTTP_H_
#include <netinet/in.h>
#include "event.h"
#include "list.h"
struct http_con {
struct sockaddr_in addr;
struct event_fd *event;
int fd;
char *req_data;
unsigned int req_size;
char **req_headers;
unsigned int req_header_cnt;
char **req_args;
unsigned int req_arg_cnt;
};
struct http_callback {
struct list_head list;
char *name;
int wildcard;
int (* callback)(struct http_con *con, void *privdata);
void *privdata;
};
int http_send_header(struct http_con *con, char *code, char *type);
int http_send_error(struct http_con *con, char *code, char *msg);
struct http_callback * http_add_cb(const char *name, int flags, int (* cb)(struct http_con *con, void *privdata), void *privdata);
int http_remove_cb(struct http_callback *cb);
int http_file_cb(struct http_con *con, void *privdata);
int http_listen_handler(int fd, void *privdata);
#endif // _HTTP_H_