12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455(**************************************************************************)(* *)(* Copyright 2018-2023 OCamlPro *)(* *)(* All rights reserved. This file is distributed under the terms of the *)(* GNU Lesser General Public License version 2.1, with the special *)(* exception on linking described in the file LICENSE. *)(* *)(**************************************************************************)moduleStringMap=Map.Make(String)typeversion=[`HTTP_1_0|`HTTP_1_1]typet={req_version:version;req_time:float;req_headers:stringlistStringMap.t;req_params:stringlistStringMap.t;req_id:Uuidm.t}letdummy={req_version=`HTTP_1_1;req_time=0.;req_headers=StringMap.empty;req_params=StringMap.empty;req_id=Uuidm.nil}letadd_paramsreqparams=letreq_params=List.fold_left(funmap(arg,l1)->matchStringMap.find_optargmapwith|Somel0->StringMap.addarg(l0@l1)map|None->StringMap.addargl1map)req.req_paramsparamsin{reqwithreq_params}letrequest?(version=`HTTP_1_1)?(headers=StringMap.empty)?(time=0.)uri=letpath_str=Uri.pathuriinletpath=List.filter(funs->s<>"")@@String.split_on_char'/'path_strinletreq_id=Uuidm.v4_gen(Random.get_state())()inletreq={req_params=StringMap.empty;req_headers=headers;req_version=version;req_time=time;req_id}inletcontent_type=matchStringMap.find_opt"content-type"headerswith|Some(c::_)->Somec|_->Noneinpath_str,path,content_type,add_paramsreq(Uri.queryuri)letfind_paramspreq=StringMap.find_optp.Param.param_idreq.req_paramsletfind_parampreq=matchfind_paramspreqwith|None->None|Somevalues->Some(String.concat","values)