Commit e15ab1576b7186e05d36425b7874d6cac6d786e3

Authored by Cédric RICARD
1 parent 4e7c11f0

[+] A function can be specified a redirection handler.

[+] An external link can be added as 'Refresh' Meta-Tag
calexium_lib/web/CXM_common.anubis
... ... @@ -130,8 +130,11 @@ public type Redirection:
130 130 redirect(String required_uri, // URI required by the client
131 131 String required_host, // value of 'Host' HTTP header sent by the client
132 132 String corresponding_uri). // URI which will be served to the client
133   -
134 133  
  134 +public type Redirections:
  135 + redirection_list(List(Redirection) redirections),
  136 + redirection_fn((String input_uri, // URI required by the client
  137 + String host) -> String f). // value of 'Host' HTTP header sent by the client
135 138  
136 139  
137 140 Now, you may also want to recover web argument values which have been encoded (by
... ...
calexium_lib/web/CXM_making_a_web_site.anubis
... ... @@ -1391,6 +1391,7 @@ public type HTML_Meta:
1391 1391 Actioner_Target target,
1392 1392 String action_name,
1393 1393 Int32 delay), // in seconds
  1394 + refresh (String url, Int32 delay), // in seconds
1394 1395 meta (String name, String content),
1395 1396 http_equiv (String name, String content),
1396 1397 generic_meta (List((String,String))),
... ... @@ -2143,17 +2144,6 @@ define Printable_tree
2143 2144 percentage(x) then ["\"",x,"%\""]
2144 2145 }.
2145 2146  
2146   -define Printable_tree
2147   - top_redirection_page
2148   - (
2149   - String common_name
2150   - ) =
2151   - [ doctype_w3c_header,
2152   - "<html><head>",
2153   - "<meta http-equiv=\"Refresh\" content=\"0; URL=javascript:void window.open('/?t=','_top')\" />",
2154   - "</head><body></body></html>"
2155   - ].
2156   -
2157 2147 public define Web_Site
2158 2148 make_web_site_description
2159 2149 (
... ... @@ -2176,7 +2166,7 @@ public define Web_Site
2176 2166 List(Web_Action($SessionTicket, $State)) actions,
2177 2167 (Maybe($SessionTicket), Maybe($State)) -> HTML_Page compute_page,
2178 2168 Int32 timeout,
2179   - List(Redirection) redirections,
  2169 + Redirections redirections,
2180 2170 String charset,
2181 2171 List(String) journal_extensions,
2182 2172 List(String) journal_headers,
... ... @@ -3982,6 +3972,8 @@ define Printable_tree
3982 3972 refresh(co,ta,an,delay) then
3983 3973 ["<meta http-equiv=\"Refresh\" content=\"",delay,"; URL=",
3984 3974 make_actioner_url(cinfo,co,ta,state_name,an,[],is_https),"\" />\n"],
  3975 + refresh(url,delay) then
  3976 + ["<meta http-equiv=\"Refresh\" content=\"",delay,"; URL=",url,"\" />\n"],
3985 3977 meta(n,c) then ["<meta name=\"",n,"\" content=\"",c,"\" />\n"],
3986 3978 http_equiv(n,c) then ["<meta http-equiv=\"",n,"\" content=\"",c,"\" />\n"],
3987 3979 generic_meta(l) then ["<meta ",
... ...
calexium_lib/web/CXM_multihost_http_server.anubis
... ... @@ -195,7 +195,7 @@ public type Web_Site_Description:
195 195 web_site_description(
196 196 List(String) common_names,
197 197 String site_directory,
198   - List(Redirection) redirections,
  198 + Redirections redirections,
199 199 String charset,
200 200 List(String) journal_extensions,
201 201 List(String) journal_headers,
... ... @@ -2800,7 +2800,7 @@ define String
2800 2800 define String
2801 2801 handle_redirection // returns the redirected URI
2802 2802 (
2803   - List(Redirection) redirections,
  2803 + Redirections redirections,
2804 2804 String uri, // original URI
2805 2805 List(HTTP_header) headers
2806 2806 ) =
... ... @@ -2808,12 +2808,17 @@ define String
2808 2808 {
2809 2809 [ ] then uri,
2810 2810 [h . t] then if h is http_header(name,value) then
2811   - if name = "host"
2812   - then handle_redirection(uri,strip_port(value,0),redirections)
2813   - else handle_redirection(redirections,uri,t)
  2811 + if redirections is
  2812 + {
  2813 + redirection_list(l) then
  2814 + if name = "host"
  2815 + then handle_redirection(uri, strip_port(value,0), l)
  2816 + else handle_redirection(redirections,uri,t)
  2817 + redirection_fn(f) then f(uri, strip_port(value,0))
  2818 + }
2814 2819 }.
2815 2820  
2816   -
  2821 +
2817 2822  
2818 2823  
2819 2824  
... ...