@@ -307,7 +307,25 @@ let create_process_cgi filename ri post_out cgi_in err_in re doc_root hostname =
307307 cgi_in
308308 err_in
309309
310-
310+ (* Copied from deprecated [Lwt_chan]. *)
311+ let lwt_chan_input_line ic =
312+ let rec loop buf =
313+ Lwt_io. read_char_opt ic >> = function
314+ | None | Some '\n' ->
315+ Lwt. return (Buffer. contents buf)
316+ | Some char ->
317+ Buffer. add_char buf char ;
318+ loop buf
319+ in
320+ Lwt_io. read_char_opt ic >> = function
321+ | Some '\n' ->
322+ Lwt. return " "
323+ | Some char ->
324+ let buf = Buffer. create 128 in
325+ Buffer. add_char buf char ;
326+ loop buf
327+ | None ->
328+ Lwt. fail End_of_file
311329
312330(* * This function makes it possible to launch a cgi script *)
313331
@@ -368,15 +386,15 @@ let recupere_cgi head re doc_root filename ri hostname =
368386 Lwt_timeout. start timeout;
369387
370388 (* A thread giving POST data to the CGI script: *)
371- let post_in_ch = Lwt_chan. out_channel_of_descr post_in in
389+ let post_in_ch = Lwt_io. of_fd ~mode: Lwt_io. output post_in in
372390 ignore
373391 (catch
374392 (fun () ->
375393 (match (Ocsigen_request_info. http_frame ri).Ocsigen_http_frame. frame_content with
376394 | None -> Lwt_unix. close post_in
377395 | Some content_post ->
378396 Ocsigen_http_com. write_stream post_in_ch content_post >> = fun () ->
379- Lwt_chan . flush post_in_ch >> = fun () ->
397+ Lwt_io . flush post_in_ch >> = fun () ->
380398 Lwt_unix. close post_in
381399 ))
382400 (* XXX Check possible errors! *)
@@ -391,9 +409,9 @@ let recupere_cgi head re doc_root filename ri hostname =
391409
392410 (* A thread listening the error output of the CGI script
393411 and writing them in warnings.log *)
394- let err_channel = Lwt_chan. in_channel_of_descr err_out in
412+ let err_channel = Lwt_io. of_fd ~mode: Lwt_io. input err_out in
395413 let rec get_errors () =
396- Lwt_chan. input_line err_channel >> = fun err ->
414+ lwt_chan_input_line err_channel >> = fun err ->
397415 Lwt_log. ign_warning ~section err;
398416 get_errors ()
399417 in ignore
0 commit comments