((f ()) handle ex => (popParams (); raise ex))
before popParams ())
- val headers = ref (StringMap.empty : string StringMap.map)
+ val headers = ref (StringMap.empty : string list StringMap.map)
fun setHeader (n, v) = headers := StringMap.insert (!headers, n, v)
fun getHeader n = StringMap.find (!headers, n)
+ fun addHeader (n, v) =
+ headers := StringMap.insert (!headers, n, case getHeader n of
+ NONE => [v]
+ | SOME vs => vs @ [v])
+ fun getSingleHeader n =
+ (case StringMap.find (!headers, n) of
+ SOME (v::_) => SOME v
+ | _ => NONE)
val text = ref ([] : string list)
fun noOutput () = !text = []
fun output () =
(TextIO.print "Status: 200\n";
- StringMap.appi (fn (n, v) => (TextIO.print n;
- TextIO.print ": ";
- TextIO.print v;
- TextIO.print "\n")) (!headers);
+ StringMap.appi (fn (n, vs) =>
+ app (fn v => (TextIO.print n;
+ TextIO.print ": ";
+ TextIO.print v;
+ TextIO.print "\n"))
+ vs) (!headers);
TextIO.print "\n";
TextIO.print (String.concat (List.rev (!text))))
else
s
in
- setHeader ("Set-Cookie", s)
+ addHeader ("Set-Cookie", s)
end
fun getCookie n =
NONE => getCgi "REMOTE_ADDR"
| h => h
+ fun plusSeconds (t, s) = Time.+ (t, Time.fromSeconds (LargeInt.fromInt s))
fun minusSeconds (t, s) = Time.- (t, Time.fromSeconds (LargeInt.fromInt s))
fun split (s, ch) =