From 9193ea964d5f2cff0b6c54234c2e4d6a534b56ee Mon Sep 17 00:00:00 2001 From: David RENE Date: Thu, 10 Jan 2008 00:55:30 +0000 Subject: [PATCH] Fix the redirection handling. --- calexium_lib/web/CXM_multihost_http_server.anubis | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/calexium_lib/web/CXM_multihost_http_server.anubis b/calexium_lib/web/CXM_multihost_http_server.anubis index e336241..bee3095 100644 --- a/calexium_lib/web/CXM_multihost_http_server.anubis +++ b/calexium_lib/web/CXM_multihost_http_server.anubis @@ -489,7 +489,8 @@ public define One --- That's all for the public part ! -------------------------------------------------- - + +define Maybe(String) get_host_header_value(List(HTTP_header) headers). define String utime_to_string @@ -2798,24 +2799,31 @@ define String Finding the 'Host' header. No redirection is performed if this header is not found. define String - handle_redirection // returns the redirected URI - ( - Redirections redirections, - String uri, // original URI - List(HTTP_header) headers - ) = + handle_redirection // returns the redirected URI + ( + Redirections redirections, + String uri, // original URI + List(HTTP_header) headers + )= + if get_host_header_value(headers) is + { + failure then uri, + success(host) then + if redirections is + { + redirection_list(l) then handle_redirection(uri, host, l) + redirection_fn(f) then f(uri, host) + } + }. + if headers is { [ ] then uri, [h . t] then if h is http_header(name,value) then - if redirections is - { - redirection_list(l) then - if name = "host" - then handle_redirection(uri, strip_port(value,0), l) - else handle_redirection(redirections,uri,t) - redirection_fn(f) then f(uri, strip_port(value,0)) - } + if name = "host" then + + else + handle_redirection(redirections,uri,t) }. -- libgit2 0.21.4