Commits

Anonymous committed 7058685

.

Comments (0)

Files changed (3)

 ;
 
 type rq_headers =
-  <
-    connection : list connection_header_val;
-    content_length : option int;
-    transfer_length : option int;
-    transfer_encoding : list transfer_encoding;
-
-    all : list (string * string);
-  >
+  { connection : list connection_header_val
+  ; content_length : option int
+  ; transfer_length : option int
+  ; transfer_encoding : list transfer_encoding
+  ; all : list (string * string);
+  }
 ;
 
 value empty_rq_headers : rq_headers =
-  object
-    method connection = [];
-    method content_length = None;
-    method transfer_encoding = [];
-    method transfer_length = None;
-    method all = [];
-  end
+  { connection = []
+  ; content_length = None
+  ; transfer_encoding = []
+  ; transfer_length = None
+  ; all = []
+  }
 ;
 
 
 
 type request =
   { rq_method : request_method
+(*
   ; rq_uri : uri
+*)
+  ; rq_request_uri__ : uri  (* uri from "GET ... HTTP/*" line, not useful *)
   ; rq_version : (int * int)
   ; rq_headers : rq_headers
   }
     )
     lst
   in
-    object
-      method connection = connection.val;
-      method content_length = content_length.val;
-      method transfer_length = transfer_length.val;
-      method transfer_encoding = transfer_encoding.val;
-      method all = lst;
-    end
+    { connection = connection.val
+    ; content_length = content_length.val
+    ; transfer_length = transfer_length.val
+    ; transfer_encoding = transfer_encoding.val
+    ; all = lst
+    }
 ;
 
 
 
 value request_has_message_body rq =
   let h = rq.rq_headers in
-     h#transfer_encoding <> []
-  || h#content_length <> None
-  || h#transfer_length <> None
+     h.transfer_encoding <> []
+  || h.content_length <> None
+  || h.transfer_length <> None
 ;
 
 (* добавляет заголовки, которые нужно вычислить на основании
     >>= fun header_lines ->
     I.return
     { rq_method = meth
-    ; rq_uri = uri
+    ; rq_request_uri__ = uri
     ; rq_version = version
     ; rq_headers = make_headers header_lines
     }
       (
         (* todo: chunked t.e. *)
         let h = request.rq_headers in
-        if List.exists ((=) `Close) h#connection
+        if List.exists ((=) `Close) h.connection
         then
           I.return `Till_eof
         else
-        if h#transfer_encoding <> []
+        if h.transfer_encoding <> []
         then
           fail "non-identity transfer encodings are not implemented"
         else
-          match h#content_length with
+          match h.content_length with
           [ None -> fail "411 Length required"
           | Some len -> I.return & `Content_length len
           ]

amall_http_server.ml

 value (post_form : request ->
   I.iteratee char (request * list (string * string))
 ) request =
-  I.printf "request headers was read ok, uri: %s.\n\
+  I.printf "request headers was read ok, request_uri: %S, uri: %S.\n\
             headers:\n%s\n===\n%!"
-       (Uri.dump_uri request.rq_uri)
+       (Uri.dump_uri request.rq_request_uri__)
+       ( (* Uri.dump_uri request.rq_uri *) "<todo>")
        (String.concat "\n" & List.map (fun (k,v) -> sprintf "%S = %S" k v)
-         request.rq_headers#all
+         request.rq_headers.all
        )
   >>= fun () ->
 (*

amall_http_service.ml

     value (server_func : disp_level -> http_server_func)
       root_disp_level
     = fun rq ->
-      let uri = rq.Amall_http.rq_uri in
+      let uri = rq.Amall_http.rq_request_uri__ in
       let segpath = segpath_of_uri uri in
       let (segpath, func) = find_handler root_disp_level segpath in
       ((func segpath) : http_server_func) rq