comparison src/settings.sml @ 1465:2f5fd248588d

getHeader and setHeader
author Adam Chlipala <adam@chlipala.net>
date Sun, 29 May 2011 14:29:26 -0400
parents 66092ce45a76
children 5018878ca645
comparison
equal deleted inserted replaced
1464:969b90b1f2f9 1465:2f5fd248588d
138 "onServerError", 138 "onServerError",
139 "kc", 139 "kc",
140 "debug", 140 "debug",
141 "naughtyDebug", 141 "naughtyDebug",
142 "rand", 142 "rand",
143 "now"] 143 "now",
144 "getHeader",
145 "setHeader"]
144 146
145 val benign = ref benignBase 147 val benign = ref benignBase
146 fun setBenignEffectful ls = benign := S.addList (benignBase, ls) 148 fun setBenignEffectful ls = benign := S.addList (benignBase, ls)
147 fun isBenignEffectful x = S.member (!benign, x) 149 fun isBenignEffectful x = S.member (!benign, x)
148 150
291 rew (!rewrites) 293 rew (!rewrites)
292 end 294 end
293 295
294 val url = ref ([] : rule list) 296 val url = ref ([] : rule list)
295 val mime = ref ([] : rule list) 297 val mime = ref ([] : rule list)
298 val request = ref ([] : rule list)
299 val response = ref ([] : rule list)
296 300
297 fun setUrlRules ls = url := ls 301 fun setUrlRules ls = url := ls
298 fun setMimeRules ls = mime := ls 302 fun setMimeRules ls = mime := ls
303 fun setRequestHeaderRules ls = request := ls
304 fun setResponseHeaderRules ls = response := ls
299 305
300 fun getUrlRules () = !url 306 fun getUrlRules () = !url
301 fun getMimeRules () = !mime 307 fun getMimeRules () = !mime
308 fun getRequestHeaderRules () = !request
309 fun getResponseHeaderRules () = !response
302 310
303 fun check f rules s = 311 fun check f rules s =
304 let 312 let
305 fun chk (ls : rule list) = 313 fun chk (ls : rule list) =
306 case ls of 314 case ls of
322 in 330 in
323 f s andalso chk (!rules) 331 f s andalso chk (!rules)
324 end 332 end
325 333
326 val checkUrl = check (fn _ => true) url 334 val checkUrl = check (fn _ => true) url
327 val checkMime = check 335
328 (CharVector.all (fn ch => Char.isAlphaNum ch orelse ch = #"/" orelse ch = #"-" orelse ch = #".")) 336 val validMime = CharVector.all (fn ch => Char.isAlphaNum ch orelse ch = #"/" orelse ch = #"-" orelse ch = #".")
329 mime 337
338 val checkMime = check validMime mime
339 val checkRequestHeader = check validMime request
340 val checkResponseHeader = check validMime response
330 341
331 342
332 type protocol = { 343 type protocol = {
333 name : string, 344 name : string,
334 compile : string, 345 compile : string,