X-Git-Url: http://git.hcoop.net/bpt/mlt.git/blobdiff_plain/16abb0f9dc821395f7644328a98d75a4aa97e83e..870af305c1ecdfeb14883690bee066e0b707757b:/src/lib/web.sml diff --git a/src/lib/web.sml b/src/lib/web.sml index ebd49fb..2394687 100644 --- a/src/lib/web.sml +++ b/src/lib/web.sml @@ -78,9 +78,17 @@ struct ((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) @@ -89,10 +97,12 @@ struct 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)))) @@ -188,7 +198,7 @@ struct else s in - setHeader ("Set-Cookie", s) + addHeader ("Set-Cookie", s) end fun getCookie n = @@ -211,6 +221,7 @@ struct 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) =