let collect_http_requests item_list =
let r = ref [] in
List.iter item_list ~f:(fun item ->
let date = item.time in
match item.content with
| `Tag _ | `Creation -> ()
| `Incoming_request hr ->
r := (hr, date, None) :: !r
| `End_of_request (hr, rl) ->
r := List.map !r ~f:(function
| (h, i, None) when h = hr -> (h, i, Some (date, rl))
| other -> other)
);
List.filter_map !r ~f:(function
| (hr, t, Some (t2, rl)) ->
Some (object
method uri = hr.uri
method date = t
method duration = (t2 -. t)
method body_length = rl.body_length
end)
| _ -> None)