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,
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