Mercurial > urweb
comparison src/settings.sml @ 1370:44a12a321150
queryString and effectfulUrl
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Sun, 26 Dec 2010 17:29:03 -0500 |
parents | 1595a738e4e9 |
children | 9a721f0722d3 |
comparison
equal
deleted
inserted
replaced
1369:1a78ca089bd0 | 1370:44a12a321150 |
---|---|
26 *) | 26 *) |
27 | 27 |
28 structure Settings :> SETTINGS = struct | 28 structure Settings :> SETTINGS = struct |
29 | 29 |
30 val urlPrefix = ref "/" | 30 val urlPrefix = ref "/" |
31 val urlPrePrefix = ref "" | |
31 val timeout = ref 0 | 32 val timeout = ref 0 |
32 val headers = ref ([] : string list) | 33 val headers = ref ([] : string list) |
33 val scripts = ref ([] : string list) | 34 val scripts = ref ([] : string list) |
34 | 35 |
35 fun getUrlPrefix () = !urlPrefix | 36 fun getUrlPrefix () = !urlPrefix |
37 fun getUrlPrePrefix () = !urlPrePrefix | |
36 fun setUrlPrefix p = | 38 fun setUrlPrefix p = |
37 urlPrefix := (if p = "" then | 39 let |
38 "/" | 40 val prefix = if p = "" then |
39 else if String.sub (p, size p - 1) <> #"/" then | 41 "/" |
40 p ^ "/" | 42 else if String.sub (p, size p - 1) <> #"/" then |
41 else | 43 p ^ "/" |
42 p) | 44 else |
45 p | |
46 | |
47 val (prepre, prefix) = | |
48 if String.isPrefix "http://" prefix then | |
49 let | |
50 val (befor, after) = Substring.splitl (fn ch => ch <> #"/") (Substring.extract (prefix, 7, NONE)) | |
51 in | |
52 if Substring.isEmpty after then | |
53 ("", prefix) | |
54 else | |
55 ("http://" ^ Substring.string befor, Substring.string after) | |
56 end | |
57 else | |
58 ("", prefix) | |
59 in | |
60 urlPrePrefix := prepre; | |
61 urlPrefix := prefix | |
62 end | |
43 | 63 |
44 fun getTimeout () = !timeout | 64 fun getTimeout () = !timeout |
45 fun setTimeout n = timeout := n | 65 fun setTimeout n = timeout := n |
46 | 66 |
47 fun getHeaders () = !headers | 67 fun getHeaders () = !headers |