From 5df79c53745fde5d6c3340a2979b1429cd5892c1 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Sat, 8 Oct 2011 20:30:28 +0200 Subject: Initial import of htcd system 1.0 Signed-off-by: Henrik Rydberg --- htc/http.htc | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 htc/http.htc (limited to 'htc/http.htc') diff --git a/htc/http.htc b/htc/http.htc new file mode 100644 index 0000000..c9a8557 --- /dev/null +++ b/htc/http.htc @@ -0,0 +1,61 @@ +\include{system.htc} +\include{tree.htc} +\include{layout.htc} +\include{upload.htc} +\include{posit.htc} +\const{server}{http://\HOST\if(\port!=80){:\port}} +\const{server.alias}(\HOST left ".") +\const{server.admin}{\ADMIN} +% +% Some special stuff +% +\def{setcookie}{xx?}{ + \resp.cookie{\1}{\2}{ +% domain=\HOST\; path=/\if(\0){; expires=\time2http{\0}} +% the domain spec above does not work on modern browsers such as firefox +% if host is not a fully qualified dns name + path=/\if(\0){; expires=\time2http{\0}} + } +} +\def{redirect}{x}{ + \if(\req.version gt "HTTP/1.0"){ + \resp.status{\HTTP.303} + }{ + \resp.status{\HTTP.302} + } + \if(\1 cnt ":"){ + \resp.location{\1} + }{ + \resp.location{\server\1} + } +} +\def{onget}{r}{ + \if("GET HEAD" which \req.method){ + \1 + } +} +\def{onpost}{r}{ + \if(\req.method eq "POST"){ + \1 + } +} +% +% Cookie allowance +% +\def{cookie.allow}{x}{ + [ok:=1;name:=first \1;val:=rest \1]; + \if(name ne ""){ + [ok=0]; + \for(i:=0)(i<\ncookie)(i+=1){ + \if(\cookie[i].name eq name && \cookie[i].val eq val)(ok=1); + } + }; + [ok] +} +% +% CRONTAB +% +\cron(211){\sync} +\cron(120){\tree.update} +\cron(300){\tempfile.update} + -- cgit v1.2.3