1 #pragma lib "libhttpd.a"
2 #pragma src "/sys/src/libhttpd"
4 typedef struct HConnect HConnect;
5 typedef struct HContent HContent;
6 typedef struct HContents HContents;
7 typedef struct HETag HETag;
8 typedef struct HFields HFields;
9 typedef struct Hio Hio;
10 typedef struct Htmlesc Htmlesc;
11 typedef struct HttpHead HttpHead;
12 typedef struct HttpReq HttpReq;
13 typedef struct HRange HRange;
14 typedef struct HSPairs HSPairs;
16 typedef struct Bin Bin;
18 #pragma incomplete Bin
45 * table of html character escape codes
58 float q; /* desirability of this kind of file */
59 int mxb; /* max uchars until worthless */
69 * generic http header with a list of tokens,
70 * each with an optional list of parameters
80 * list of pairs a strings
81 * used for tag=val pairs for a search or form submission,
82 * and attribute=value pairs in headers.
92 * byte ranges within a file
96 int suffix; /* is this a suffix request? */
98 ulong stop; /* ~0UL -> not given */
103 * list of http/1.1 entity tags
114 * supports chunked transfer encoding
115 * and initialization of the input buffer from a string.
129 Hio *hh; /* next lower layer Hio, or nil if reads from fd */
130 int fd; /* associated file descriptor */
131 ulong seek; /* of start */
132 uchar state; /* state of the file */
133 uchar xferenc; /* chunked transfer encoding state */
134 uchar *pos; /* current position in the buffer */
135 uchar *stop; /* last character active in the buffer */
136 uchar *start; /* start of data buffer */
137 ulong bodylen; /* remaining length of message body */
152 HSPairs *searchpairs;
160 int closeit; /* http1.1 close connection after this request? */
161 uchar persist; /* http/1.1 requests a persistent connection */
163 uchar expectcont; /* expect a 100-continue */
164 uchar expectother; /* expect anything else; should reject with ExpectFail */
165 ulong contlen; /* if != ~0UL, length of included message body */
166 HFields *transenc; /* if present, encoding of included message body */
180 char *authuser; /* authorization info */
182 HSPairs *cookie; /* if present, list of cookies */
183 HSPairs *authinfo; /* digest authorization */
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 */
200 char *scheme; /* "http" vs. "https" */
201 char *port; /* may be arbitrary, i.e., neither 80 nor 443 */
208 ulong reqtime; /* time at start of request */
209 char xferbuf[HBufSize]; /* buffer for making up or transferring data */
210 uchar header[HBufSize + 2]; /* room for \n\0 */
218 * configuration for all connections within the server
220 extern char* hmydomain;
221 extern char* hversion;
222 extern Htmlesc htmlesc[];
225 * .+2,/^$/ | sort -bd +1
227 void *halloc(HConnect *c, ulong size);
228 Hio *hbodypush(Hio *hh, ulong len, HFields *te);
229 int hbuflen(Hio *h, void *p);
230 int hcheckcontent(HContent*, HContent*, char*, int);
232 ulong hdate2sec(char*);
234 int hfail(HConnect*, int, ...);
237 int hgethead(HConnect *c, int many);
238 int hinit(Hio*, int, int);
239 int hiserror(Hio *h);
241 int hload(Hio*, char*);
243 HContent *hmkcontent(HConnect *c, char *generic, char *specific, HContent *next);
244 HFields *hmkhfields(HConnect *c, char *s, HSPairs *p, HFields *next);
245 char *hmkmimeboundary(HConnect *c);
246 HSPairs *hmkspairs(HConnect *c, char *s, char *t, HSPairs *next);
247 int hmoved(HConnect *c, char *uri);
248 void hokheaders(HConnect *c);
249 int hparseheaders(HConnect*, int timeout);
250 HSPairs *hparsequery(HConnect *c, char *search);
251 int hparsereq(HConnect *c, int timeout);
252 int hprint(Hio*, char*, ...);
253 int hputc(Hio*, int);
254 void *hreadbuf(Hio *h, void *vsave);
255 int hredirected(HConnect *c, char *how, char *uri);
256 void hreqcleanup(HConnect *c);
257 HFields *hrevhfields(HFields *hf);
258 HSPairs *hrevspairs(HSPairs *sp);
259 char *hstrdup(HConnect *c, char *s);
260 int http11(HConnect*);
262 char *httpunesc(HConnect *c, char *s);
263 int hunallowed(HConnect *, char *allowed);
267 char *hurlunesc(HConnect *c, char *s);
268 int hwrite(Hio*, void*, int);
269 int hxferenc(Hio*, int);
271 #pragma varargck argpos hprint 2
274 * D is httpd format date conversion
275 * U is url escape convertsion
276 * H is html escape conversion
278 #pragma varargck type "D" long
279 #pragma varargck type "D" ulong
280 #pragma varargck type "U" char*
281 #pragma varargck type "H" char*