2 #pragma lib "libhttpd.a"
3 #pragma src "/sys/src/libhttpd"
6 typedef struct HConnect HConnect;
7 typedef struct HContent HContent;
8 typedef struct HContents HContents;
9 typedef struct HETag HETag;
10 typedef struct HFields HFields;
11 typedef struct Hio Hio;
12 typedef struct Htmlesc Htmlesc;
13 typedef struct HttpHead HttpHead;
14 typedef struct HttpReq HttpReq;
15 typedef struct HRange HRange;
16 typedef struct HSPairs HSPairs;
19 typedef struct Bin Bin;
48 * table of html character escape codes
61 float q; /* desirability of this kind of file */
62 int mxb; /* max uchars until worthless */
72 * generic http header with a list of tokens,
73 * each with an optional list of parameters
83 * list of pairs a strings
84 * used for tag=val pairs for a search or form submission,
85 * and attribute=value pairs in headers.
95 * byte ranges within a file
99 int suffix; /* is this a suffix request? */
101 ulong stop; /* ~0UL -> not given */
106 * list of http/1.1 entity tags
117 * supports chunked transfer encoding
118 * and initialization of the input buffer from a string.
132 Hio *hh; /* next lower layer Hio, or nil if reads from fd */
133 int fd; /* associated file descriptor */
134 ulong seek; /* of start */
135 uchar state; /* state of the file */
136 uchar xferenc; /* chunked transfer encoding state */
137 uchar *pos; /* current position in the buffer */
138 uchar *stop; /* last character active in the buffer */
139 uchar *start; /* start of data buffer */
140 ulong bodylen; /* remaining length of message body */
162 int closeit; /* http1.1 close connection after this request? */
163 uchar persist; /* http/1.1 requests a persistent connection */
165 uchar expectcont; /* expect a 100-continue */
166 uchar expectother; /* expect anything else; should reject with ExpectFail */
167 ulong contlen; /* if != ~0UL, length of included message body */
168 HFields *transenc; /* if present, encoding of included message body */
182 char *authuser; /* authorization info */
186 * experimental headers
193 * all of the state for a particular connection
197 void *private; /* for the library clients */
198 void (*replog)(HConnect*, char*, ...); /* called when reply sent */
205 ulong reqtime; /* time at start of request */
206 char xferbuf[HBufSize]; /* buffer for making up or transferring data */
207 uchar header[HBufSize + 2]; /* room for \n\0 */
215 * configuration for all connections within the server
217 extern char* hmydomain;
218 extern char* hversion;
219 extern Htmlesc htmlesc[];
222 * .+2,/^$/ | sort -bd +1
224 void *halloc(HConnect *c, ulong size);
225 Hio *hbodypush(Hio *hh, ulong len, HFields *te);
226 int hbuflen(Hio *h, void *p);
227 int hcheckcontent(HContent*, HContent*, char*, int);
229 ulong hdate2sec(char*);
231 int hfail(HConnect*, int, ...);
234 int hgethead(HConnect *c, int many);
235 int hinit(Hio*, int, int);
236 int hiserror(Hio *h);
237 int hload(Hio*, char*);
239 HContent *hmkcontent(HConnect *c, char *generic, char *specific, HContent *next);
240 HFields *hmkhfields(HConnect *c, char *s, HSPairs *p, HFields *next);
241 char *hmkmimeboundary(HConnect *c);
242 HSPairs *hmkspairs(HConnect *c, char *s, char *t, HSPairs *next);
243 int hmoved(HConnect *c, char *uri);
244 void hokheaders(HConnect *c);
245 int hparseheaders(HConnect*, int timeout);
246 HSPairs *hparsequery(HConnect *c, char *search);
247 int hparsereq(HConnect *c, int timeout);
248 int hprint(Hio*, char*, ...);
249 int hputc(Hio*, int);
250 void *hreadbuf(Hio *h, void *vsave);
251 int hredirected(HConnect *c, char *how, char *uri);
252 void hreqcleanup(HConnect *c);
253 HFields *hrevhfields(HFields *hf);
254 HSPairs *hrevspairs(HSPairs *sp);
255 char *hstrdup(HConnect *c, char *s);
256 int http11(HConnect*);
258 char *httpunesc(HConnect *c, char *s);
259 int hunallowed(HConnect *, char *allowed);
263 char *hurlunesc(HConnect *c, char *s);
264 int hwrite(Hio*, void*, int);
265 int hxferenc(Hio*, int);
268 #pragma varargck argpos hprint 2
271 * D is httpd format date conversion
272 * U is url escape convertsion
273 * H is html escape conversion
276 #pragma varargck type "D" long
277 #pragma varargck type "D" ulong
278 #pragma varargck type "U" char*
279 #pragma varargck type "H" char*