summaryrefslogtreecommitdiff
path: root/htc/http.htc
blob: c9a8557ebcb25b37ff6c45c913204763fcd27847 (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
55
56
57
58
59
60
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}