rename time into start_time

This commit is contained in:
Simon Cruanes 2021-12-16 00:26:07 -05:00 committed by GitHub
parent 672e33c827
commit 7b14cbd6a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View file

@ -367,7 +367,7 @@ module Request = struct
path_components: string list;
query: (string*string) list;
body: 'body;
time: float;
start_time: float;
}
let headers self = self.headers
@ -375,7 +375,7 @@ module Request = struct
let meth self = self.meth
let path self = self.path
let body self = self.body
let time self = self.time
let start_time self = self.start_time
let non_query_path self = Tiny_httpd_util.get_non_query_path self.path
@ -487,7 +487,7 @@ module Request = struct
let parse_req_start ~buf (bs:byte_stream) : unit t option resp_result =
try
let line = Byte_stream.read_line ~buf bs in
let time = Unix.gettimeofday () in
let start_time = Unix.gettimeofday () in
let meth, path =
try
let m, p, v = Scanf.sscanf line "%s %s HTTP/1.%d\r" (fun x y z->x,y,z) in
@ -513,7 +513,7 @@ module Request = struct
| Error e -> bad_reqf 400 "invalid query: %s" e
in
Ok (Some {meth; query; host; path; path_components;
headers; body=(); time})
headers; body=(); start_time; })
with
| End_of_file | Sys_error _ -> Ok None
| Bad_req (c,s) -> Error (c,s)

View file

@ -281,8 +281,9 @@ module Request : sig
val body : 'b t -> 'b
(** Request body, possibly empty. *)
val time : 'b t -> float
(** time (from [Unix.gettimeofday] after parsing the first line*)
val start_time : _ t -> float
(** time stamp (from {!Unix.gettimeofday}) after parsing the first line of the request
@since NEXT_RELEASE *)
val limit_body_size : max_size:int -> byte_stream t -> byte_stream t
(** Limit the body size to [max_size] bytes, or return