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,8 +130,11 @@ public type Redirection:
130 redirect(String required_uri, // URI required by the client 130 redirect(String required_uri, // URI required by the client
131 String required_host, // value of 'Host' HTTP header sent by the client 131 String required_host, // value of 'Host' HTTP header sent by the client
132 String corresponding_uri). // URI which will be served to the client 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 Now, you may also want to recover web argument values which have been encoded (by 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,6 +1391,7 @@ public type HTML_Meta:
1391 Actioner_Target target, 1391 Actioner_Target target,
1392 String action_name, 1392 String action_name,
1393 Int32 delay), // in seconds 1393 Int32 delay), // in seconds
  1394 + refresh (String url, Int32 delay), // in seconds
1394 meta (String name, String content), 1395 meta (String name, String content),
1395 http_equiv (String name, String content), 1396 http_equiv (String name, String content),
1396 generic_meta (List((String,String))), 1397 generic_meta (List((String,String))),
@@ -2143,17 +2144,6 @@ define Printable_tree @@ -2143,17 +2144,6 @@ define Printable_tree
2143 percentage(x) then ["\"",x,"%\""] 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 public define Web_Site 2147 public define Web_Site
2158 make_web_site_description 2148 make_web_site_description
2159 ( 2149 (
@@ -2176,7 +2166,7 @@ public define Web_Site @@ -2176,7 +2166,7 @@ public define Web_Site
2176 List(Web_Action($SessionTicket, $State)) actions, 2166 List(Web_Action($SessionTicket, $State)) actions,
2177 (Maybe($SessionTicket), Maybe($State)) -> HTML_Page compute_page, 2167 (Maybe($SessionTicket), Maybe($State)) -> HTML_Page compute_page,
2178 Int32 timeout, 2168 Int32 timeout,
2179 - List(Redirection) redirections, 2169 + Redirections redirections,
2180 String charset, 2170 String charset,
2181 List(String) journal_extensions, 2171 List(String) journal_extensions,
2182 List(String) journal_headers, 2172 List(String) journal_headers,
@@ -3982,6 +3972,8 @@ define Printable_tree @@ -3982,6 +3972,8 @@ define Printable_tree
3982 refresh(co,ta,an,delay) then 3972 refresh(co,ta,an,delay) then
3983 ["<meta http-equiv=\"Refresh\" content=\"",delay,"; URL=", 3973 ["<meta http-equiv=\"Refresh\" content=\"",delay,"; URL=",
3984 make_actioner_url(cinfo,co,ta,state_name,an,[],is_https),"\" />\n"], 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 meta(n,c) then ["<meta name=\"",n,"\" content=\"",c,"\" />\n"], 3977 meta(n,c) then ["<meta name=\"",n,"\" content=\"",c,"\" />\n"],
3986 http_equiv(n,c) then ["<meta http-equiv=\"",n,"\" content=\"",c,"\" />\n"], 3978 http_equiv(n,c) then ["<meta http-equiv=\"",n,"\" content=\"",c,"\" />\n"],
3987 generic_meta(l) then ["<meta ", 3979 generic_meta(l) then ["<meta ",
calexium_lib/web/CXM_multihost_http_server.anubis
@@ -195,7 +195,7 @@ public type Web_Site_Description: @@ -195,7 +195,7 @@ public type Web_Site_Description:
195 web_site_description( 195 web_site_description(
196 List(String) common_names, 196 List(String) common_names,
197 String site_directory, 197 String site_directory,
198 - List(Redirection) redirections, 198 + Redirections redirections,
199 String charset, 199 String charset,
200 List(String) journal_extensions, 200 List(String) journal_extensions,
201 List(String) journal_headers, 201 List(String) journal_headers,
@@ -2800,7 +2800,7 @@ define String @@ -2800,7 +2800,7 @@ define String
2800 define String 2800 define String
2801 handle_redirection // returns the redirected URI 2801 handle_redirection // returns the redirected URI
2802 ( 2802 (
2803 - List(Redirection) redirections, 2803 + Redirections redirections,
2804 String uri, // original URI 2804 String uri, // original URI
2805 List(HTTP_header) headers 2805 List(HTTP_header) headers
2806 ) = 2806 ) =
@@ -2808,12 +2808,17 @@ define String @@ -2808,12 +2808,17 @@ define String
2808 { 2808 {
2809 [ ] then uri, 2809 [ ] then uri,
2810 [h . t] then if h is http_header(name,value) then 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