chibipub

experimental activitypub node in C
git clone git://jb55.com/chibipub
Log | Files | Refs | README | LICENSE

http.h (947B)


      1 #ifndef CHIBIPUB_HTTP
      2 #define CHIBIPUB_HTTP
      3 
      4 #include "cursor.h"
      5 #include "errors.h"
      6 
      7 #include <netinet/in.h>
      8 
      9 struct parser {
     10 	struct cursor cur;
     11 	struct cursor arena;
     12 };
     13 
     14 struct http_header {
     15 	char *name;
     16 	char *value;
     17 	struct http_header *next;
     18 };
     19 
     20 struct client {
     21 	int socket;
     22 	FILE *socket_file;
     23 	struct sockaddr_in sockaddr;
     24 	const char *addr_str;
     25 };
     26 
     27 struct http_req {
     28 	char *method;
     29 	char *path;
     30 	char *ver;
     31 	unsigned char *body;
     32 	unsigned int body_len;
     33 	struct client client;
     34 	struct http_header *headers;
     35 	struct errors errs;
     36 };
     37 
     38 void init_http_req(struct http_req *req);
     39 int get_header(struct http_header *header, const char *match, const char **result);
     40 int parse_http_request(struct http_req *req, struct parser *p, int size);
     41 void print_http_request(struct http_req *req);
     42 void http_write_status(struct http_req *req, const char *status);
     43 void http_write_header(struct http_req *req, const char *status);
     44 
     45 #endif /* CHIBIPUB_HTTP */