From: Stefano Zacchiroli Date: Sun, 5 Jan 2003 14:12:57 +0000 (+0000) Subject: - case insensitive handling of header names X-Git-Tag: v0_3_99~92 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=6b6f542566b73236e1146dc1dba4ef7219d8ffe7;p=helm.git - case insensitive handling of header names --- diff --git a/helm/DEVEL/ocaml-http/http_message.ml b/helm/DEVEL/ocaml-http/http_message.ml index 24621e05d..2de1e1cbe 100644 --- a/helm/DEVEL/ocaml-http/http_message.ml +++ b/helm/DEVEL/ocaml-http/http_message.ml @@ -24,15 +24,15 @@ open Http_constants;; open Http_types;; open Printf;; -class virtual message ~body ~headers ~version ~clisockaddr ~srvsockaddr = + (* remove all bindings of 'name' from hashtbl 'tbl' *) +let rec hashtbl_remove_all tbl name = + if not (Hashtbl.mem tbl name) then + raise (Header_not_found name); + Hashtbl.remove tbl name; + if Hashtbl.mem tbl name then hashtbl_remove_all tbl name +;; - (* remove all bindings of 'name' from hashtbl 'tbl' *) - let rec hashtbl_remove_all tbl name = - if not (Hashtbl.mem tbl name) then - raise (Header_not_found name); - Hashtbl.remove tbl name; - if Hashtbl.mem tbl name then hashtbl_remove_all tbl name - in +class virtual message ~body ~headers ~version ~clisockaddr ~srvsockaddr = let ((cliaddr, cliport), (srvaddr, srvport)) = (Http_misc.explode_sockaddr clisockaddr, @@ -64,20 +64,26 @@ class virtual message ~body ~headers ~version ~clisockaddr ~srvsockaddr = method addBodyBuf b = Buffer.add_buffer _contentsBuf b method addHeader ~name ~value = + let name = String.lowercase name in Http_parser_sanity.heal_header (name, value); Hashtbl.add _headers name value method addHeaders = List.iter (fun (name, value) -> self#addHeader ~name ~value) method replaceHeader ~name ~value = + let name = String.lowercase name in Http_parser_sanity.heal_header (name, value); Hashtbl.replace _headers name value method replaceHeaders = List.iter (fun (name, value) -> self#replaceHeader ~name ~value) - method removeHeader ~name = hashtbl_remove_all _headers name - method hasHeader ~name = Hashtbl.mem _headers name + method removeHeader ~name = + let name = String.lowercase name in + hashtbl_remove_all _headers name + method hasHeader ~name = + let name = String.lowercase name in + Hashtbl.mem _headers name method header ~name = - if not (self#hasHeader name) then - raise (Header_not_found name); + if not (self#hasHeader name) then raise (Header_not_found name); + let name = String.lowercase name in String.concat ", " (List.rev (Hashtbl.find_all _headers name)) method headers = List.rev