Commit 9193ea964d5f2cff0b6c54234c2e4d6a534b56ee

Authored by David RENE
1 parent e15ab157

Fix the redirection handling.

Showing 1 changed file with 23 additions and 15 deletions   Show diff stats
calexium_lib/web/CXM_multihost_http_server.anubis
... ... @@ -489,7 +489,8 @@ public define One
489 489  
490 490  
491 491 --- That's all for the public part ! --------------------------------------------------
492   -
  492 +
  493 +define Maybe(String) get_host_header_value(List(HTTP_header) headers).
493 494  
494 495 define String
495 496 utime_to_string
... ... @@ -2798,24 +2799,31 @@ define String
2798 2799 Finding the 'Host' header. No redirection is performed if this header is not found.
2799 2800  
2800 2801 define String
2801   - handle_redirection // returns the redirected URI
2802   - (
2803   - Redirections redirections,
2804   - String uri, // original URI
2805   - List(HTTP_header) headers
2806   - ) =
  2802 + handle_redirection // returns the redirected URI
  2803 + (
  2804 + Redirections redirections,
  2805 + String uri, // original URI
  2806 + List(HTTP_header) headers
  2807 + )=
  2808 + if get_host_header_value(headers) is
  2809 + {
  2810 + failure then uri,
  2811 + success(host) then
  2812 + if redirections is
  2813 + {
  2814 + redirection_list(l) then handle_redirection(uri, host, l)
  2815 + redirection_fn(f) then f(uri, host)
  2816 + }
  2817 + }.
  2818 +
2807 2819 if headers is
2808 2820 {
2809 2821 [ ] then uri,
2810 2822 [h . t] then if h is http_header(name,value) then
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   - }
  2823 + if name = "host" then
  2824 +
  2825 + else
  2826 + handle_redirection(redirections,uri,t)
2819 2827 }.
2820 2828  
2821 2829  
... ...