@@ -659,7 +659,7 @@ type t = {
659659 backend : (module IO_BACKEND );
660660 mutable tcp_server : IO.TCP_server .t option ;
661661 buf_size : int ;
662- mutable handler : string Request .t -> Response .t ;
662+ mutable handler : byte_stream Request .t -> Response .t ;
663663 (* * toplevel handler, if any *)
664664 mutable middlewares : (int * Middleware .t ) list ; (* * Global middlewares *)
665665 mutable middlewares_sorted : (int * Middleware .t ) list lazy_t ;
@@ -920,7 +920,8 @@ module Unix_tcp_server_ = struct
920920 after_init tcp_server;
921921
922922 (* how to handle a single client *)
923- let handle_client_unix_ (client_sock : Unix.file_descr ) (client_addr : Unix.sockaddr ) : unit =
923+ let handle_client_unix_ (client_sock : Unix.file_descr )
924+ (client_addr : Unix.sockaddr ) : unit =
924925 Unix. (setsockopt_float client_sock SO_RCVTIMEO self.timeout);
925926 Unix. (setsockopt_float client_sock SO_SNDTIMEO self.timeout);
926927 let oc =
@@ -1025,7 +1026,9 @@ let client_handle_for (self : t) ~client_addr ic oc : unit =
10251026 while ! continue && running self do
10261027 _debug (fun k -> k " read next request" );
10271028 let (module B ) = self.backend in
1028- match Request. parse_req_start ~client_addr ~get_time_s: B. get_time_s ~buf is with
1029+ match
1030+ Request. parse_req_start ~client_addr ~get_time_s: B. get_time_s ~buf is
1031+ with
10291032 | Ok None -> continue := false (* client is done *)
10301033 | Error (c , s ) ->
10311034 (* connection error, close *)
@@ -1042,13 +1045,7 @@ let client_handle_for (self : t) ~client_addr ic oc : unit =
10421045 let base_handler =
10431046 match find_map (fun ph -> ph req) self.path_handlers with
10441047 | Some f -> unwrap_resp_result f
1045- | None ->
1046- fun _oc req ~resp ->
1047- let body_str =
1048- Pool. with_resource self.buf_pool @@ fun buf ->
1049- Request. read_body_full ~buf req
1050- in
1051- resp (self.handler body_str)
1048+ | None -> fun _oc req ~resp -> resp (self.handler req)
10521049 in
10531050
10541051 (* handle expect/continue *)
0 commit comments