summaryrefslogtreecommitdiff
path: root/appl/svc/webget/wgutils.m
blob: 36a5bdb6bb84ac611be86c9604ad97521fa6167e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
WebgetUtils: module
{
	PATH: con "/dis/svc/webget/wgutils.dis";

	Req: adt
	{
		index:	int;
		method:	string;
		bodylen:	int;
		reqid:	string;
		loc:		string;
		types:	string;
		cachectl:	string;
		auth:		string;
		body:	array of byte;
		url:		ref Url->ParsedUrl;
		reply:	ref Message->Msg;
	};

	Fid: adt
	{
		fid:		int;
		link:		cyclic ref Fid;
		reqs:		array of ref Req;
		writer:	int;
		readr:	int;
		nbyte:	int;
		nread:	int;
		rc:		Sys->Rread;
	};

	M: Message;
	B: Bufio;
	S: String;
	U: Url;
	DI: Dial;

	# media types (must track mnames array in wgutils.b)
	UnknownType,
	TextPlain, TextHtml,
	ApplPostscript, ApplRtf, ApplPdf,
	ImageJpeg, ImageGif, ImageIef, ImageTiff,
	ImageXCompressed, ImageXCompressed2, ImageXXBitmap,
	AudioBasic,
	VideoMpeg, VideoQuicktime, Soap, TextXml: con iota;

	init : fn(m: Message, s: String, b: Bufio, u: Url, di: Dial, logfd: ref Sys->FD);
	usererr: fn(r: ref Req, msg: string) : ref Message->Msg;
	okprefix: fn(r: ref Req, mrep: ref Message->Msg);
	getdata: fn(io: ref Bufio->Iobuf, m: ref Message->Msg,
					accept: string, url: ref Url->ParsedUrl) : string;
	fixaccept: fn(a: string) : string;
	log: fn(c: ref Fid, msg: string);
};