60 \- routines for creating an http server
68 typedef struct HConnect HConnect;
69 typedef struct HContent HContent;
70 typedef struct HContents HContents;
71 typedef struct HETag HETag;
72 typedef struct HFields HFields;
73 typedef struct Hio Hio;
74 typedef struct Htmlesc Htmlesc;
75 typedef struct HttpHead HttpHead;
76 typedef struct HttpReq HttpReq;
77 typedef struct HRange HRange;
78 typedef struct HSPairs HSPairs;
80 typedef struct Bin Bin;
81 .ta \w'\fLHContents 'u +\w'\fLHContentsxx 'u +\w'\fLheader[HBufSize + 2]; 'u
94 float q; /* desirability of this kind of file */
95 int mxb; /* max uchars until worthless */
105 * generic http header with a list of tokens,
106 * each with an optional list of parameters
116 * list of pairs a strings
117 * used for tag=val pairs for a search or form submission,
118 * and attribute=value pairs in headers.
128 * byte ranges within a file
132 int suffix; /* is this a suffix request? */
134 ulong stop; /* ~0UL -> not given */
139 * list of http/1.1 entity tags
150 * supports chunked transfer encoding
151 * and initialization of the input buffer from a string.
165 Hio *hh; /* next lower layer Hio, or nil if reads from fd */
166 int fd; /* associated file descriptor */
167 ulong seek; /* of start */
168 uchar state; /* state of the file */
169 uchar xferenc; /* chunked transfer encoding state */
170 uchar *pos; /* current position in the buffer */
171 uchar *stop; /* last character active in the buffer */
172 uchar *start; /* start of data buffer */
173 ulong bodylen; /* remaining length of message body */
195 int closeit; /* http1.1 close connection after this request? */
196 uchar persist; /* http/1.1 requests a persistent connection */
198 uchar expectcont; /* expect a 100-continue */
199 uchar expectother; /* expect anything else; should reject with ExpectFail */
200 ulong contlen; /* if != ~0UL, length of included message body */
201 HFields *transenc; /* if present, encoding of included message body */
215 char *authuser; /* authorization info */
219 * experimental headers
226 * all of the state for a particular connection
230 void *private; /* for the library clients */
231 void (*replog)(HConnect*, char*, ...); /* called when reply sent */
238 ulong reqtime; /* time at start of request */
239 char xferbuf[HBufSize]; /* buffer for making up or transferring data */
240 uchar header[HBufSize + 2]; /* room for \\n\\0 */
248 * configuration for all connections within the server
250 extern char *hmydomain;
251 extern char *hversion;
252 extern Htmlesc htmlesc[];
254 void *halloc(HConnect *c, ulong size);
255 Hio *hbodypush(Hio *hh, ulong len, HFields *te);
256 int hbuflen(Hio *h, void *p);
257 int hcheckcontent(HContent*, HContent*, char*, int);
259 ulong hdate2sec(char*);
261 int hfail(HConnect*, int, ...);
264 int hgethead(HConnect *c, int many);
265 int hinit(Hio*, int, int);
266 int hiserror(Hio *h);
267 int hload(Hio*, char*);
269 HContent *hmkcontent(HConnect *c, char *generic, char *specific, HContent *next);
270 HFields *hmkhfields(HConnect *c, char *s, HSPairs *p, HFields *next);
271 char *hmkmimeboundary(HConnect *c);
272 HSPairs *hmkspairs(HConnect *c, char *s, char *t, HSPairs *next);
273 int hmoved(HConnect *c, char *uri);
274 void hokheaders(HConnect *c);
275 int hparseheaders(HConnect*, int timeout);
276 HSPairs *hparsequery(HConnect *c, char *search);
277 int hparsereq(HConnect *c, int timeout);
278 int hprint(Hio*, char*, ...);
279 int hputc(Hio*, int);
280 void *hreadbuf(Hio *h, void *vsave);
281 int hredirected(HConnect *c, char *how, char *uri);
282 void hreqcleanup(HConnect *c);
283 HFields *hrevhfields(HFields *hf);
284 HSPairs *hrevspairs(HSPairs *sp);
285 char *hstrdup(HConnect *c, char *s);
286 int http11(HConnect*);
288 char *httpunesc(HConnect *c, char *s);
289 int hunallowed(HConnect *, char *allowed);
293 char *hurlunesc(HConnect *c, char *s);
294 int hvprint(Hio*, char*, va_list);
295 int hwrite(Hio*, void*, int);
296 int hxferenc(Hio*, int);
299 For now, look at the source, or
306 This is a rough implementation and many details are going to change.