lib: Added bufio variants of parseresponse/parseheaders/writeresp.
[ashd.git] / lib / req.h
1 #ifndef _LIB_HTREQ_H
2 #define _LIB_HTREQ_H
3
4 #include <stdio.h>
5
6 struct bufio;
7
8 struct hthead {
9     char *method, *url, *ver, *msg;
10     int code;
11     char *rest;
12     char ***headers;
13     int noheaders;
14 };
15
16 struct hthead *mkreq(char *method, char *url, char *ver);
17 struct hthead *mkresp(int code, char *msg, char *ver);
18 void freehthead(struct hthead *head);
19 char *getheader(struct hthead *head, char *name);
20 void headpreheader(struct hthead *head, const char *name, const char *val);
21 void headappheader(struct hthead *head, const char *name, const char *val);
22 void headrmheader(struct hthead *head, const char *name);
23 int sendreq2(int sock, struct hthead *req, int fd, int flags);
24 int sendreq(int sock, struct hthead *req, int fd);
25 int recvreq(int sock, struct hthead **reqp);
26 void replrest(struct hthead *head, char *rest);
27 int parseheaders(struct hthead *head, FILE *in);
28 int parseheadersb(struct hthead *head, struct bufio *in);
29 struct hthead *parseresponse(FILE *in);
30 struct hthead *parseresponseb(struct bufio *in);
31 int writeresp(FILE *out, struct hthead *resp);
32 int writerespb(struct bufio *out, struct hthead *resp);
33 char *unquoteurl(char *in);
34
35 #endif