Added subject facet browsing, beginning of relevance ranking
[pazpar2-moved-to-github.git] / http.h
1 #ifndef HTTP_H
2 #define HTTP_H
3
4 // Generic I/O buffer
5 struct http_buf
6 {
7 #define HTTP_BUF_SIZE 4096
8     char buf[4096];
9     int offset;
10     int len;
11     struct http_buf *next;
12 };
13
14 struct http_channel
15 {
16     IOCHAN iochan;
17     struct http_buf *iqueue;
18     struct http_buf *oqueue;
19     char version[10];
20     struct http_proxy *proxy;
21     NMEM nmem;
22     WRBUF wrbuf;
23 };
24
25 struct http_proxy //  attached to iochan for proxy connection
26 {
27     IOCHAN iochan;
28     struct http_channel *channel;
29     struct http_buf *oqueue;
30 };
31
32 struct http_header
33 {
34     char *name;
35     char *value;
36     struct http_header *next;
37 };
38
39 struct http_argument
40 {
41     char *name;
42     char *value;
43     struct http_argument *next;
44 };
45
46 struct http_request
47 {
48     struct http_channel *channel;
49     char http_version[20];
50     char method[20];
51     char *path;
52     struct http_header *headers;
53     struct http_argument *arguments;
54 };
55
56 struct http_response
57 {
58     char code[4];
59     char *msg;
60     struct http_channel *channel;
61     struct http_header *headers;
62     char *payload;
63 };
64
65 void http_set_proxyaddr(char *url);
66 void http_init(int port);
67 void http_addheader(struct http_response *r, const char *name, const char *value);
68 char *http_argbyname(struct http_request *r, char *name);
69 char *http_headerbyname(struct http_request *r, char *name);
70 struct http_response *http_create_response(struct http_channel *c);
71
72 /*
73  * Local variables:
74  * c-basic-offset: 4
75  * indent-tabs-mode: nil
76  * End:
77  * vim: shiftwidth=4 tabstop=8 expandtab
78  */
79 #endif