]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/DEVEL/ocaml-http/http_response.ml
- split http_parser module (all code that parse http requests and
[helm.git] / helm / DEVEL / ocaml-http / http_response.ml
index b71d887fc576327b1322f22a2624646414cf9496..dd145b84094ccd364a70b34f56b57846f86004d2 100644 (file)
@@ -40,7 +40,8 @@ class response =
   let status_line_re = Pcre.regexp "^(HTTP/\d\.\d) (\d{3}) (.*)$" in
   object (self)
     val mutable version = Http_common.http_version
-    val mutable code = default_code val mutable reason: string option = None
+    val mutable code = default_code
+    val mutable reason: string option = None
     val contentsBuf = Buffer.create 1024
     val headers = Hashtbl.create 11
 
@@ -87,26 +88,18 @@ class response =
     method addContents s = Buffer.add_string contentsBuf s
     method addContentsBuf b = Buffer.add_buffer contentsBuf b
 
-      (** adds an header named 'name' with value 'value', if an header with the
-      same name exists, the new value is considered an addition to the header as
-      specified in RFC 2616, thus getting value for this header will return a
-      comma separated list of values provided via 'addHeader' *)
     method addHeader ~name ~value = Hashtbl.add headers name value
-      (** set the value of header 'name' to 'value', removing all previous
-      values if any *)
+      (* FIXME duplication of code between this and send_basic_headers *)
+    method addBasicHeaders =
+      self#addHeader ~name:"Date" ~value:(Http_misc.date_822 ());
+      self#addHeader ~name:"Server" ~value:(Http_common.server_string)
     method replaceHeader ~name ~value = Hashtbl.replace headers name value
-      (** remove the header named 'name', please note that this remove all
-      values provided for this header *)
     method removeHeader ~name = hashtbl_remove_all headers name
     method hasHeader ~name = Hashtbl.mem headers name
-      (** @return value of header 'name', if multiple values were provided for
-      header 'name', the return value will be a comma separated list of
-      provided values as stated in RFC 2616 *)
     method header ~name =
       if not (self#hasHeader name) then
         raise (Header_not_found name);
       String.concat ", " (List.rev (Hashtbl.find_all headers name))
-      (** @return all headers as a list of pairs <name, value> *)
     method headers =
       List.rev
         (Hashtbl.fold