Skip to content

Commit 6b45357

Browse files
committed
Adapt to Ocsigen_response changes
The type for a server response changed from `Cohttp_lwt.Body.t` to `Ocsigen_response.Body.t`.
1 parent 0bb1a6a commit 6b45357

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

src/lib/eliom_mkreg.server.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ let send_with_cookies
138138
in
139139
(* TODO: do not add header when no cookies *)
140140
let response =
141-
let response, _ = Ocsigen_response.to_cohttp result in
141+
let response = Ocsigen_response.response result in
142142
let headers =
143143
Cohttp.Header.add
144144
(Cohttp.Response.headers response)

src/lib/eliom_registration.server.ml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ module Html_base = struct
129129
let send ?options:_ ?charset ?code ?content_type ?headers c =
130130
let status = Eliom_lib.Option.map Cohttp.Code.status_of_code code
131131
and content_type = content_type_html content_type
132-
and body = Cohttp_lwt.Body.of_string (Format.asprintf "%a" out c) in
132+
and body = Ocsigen_response.Body.of_string (Format.asprintf "%a" out c) in
133133
result_of_content ?charset ?headers ?status ~content_type body
134134
end
135135

@@ -148,9 +148,8 @@ module Flow5_base = struct
148148
Eliom_content.Html.Printer.pp_elt ~encode ()
149149

150150
let body l =
151-
Lwt_stream.of_list l
152-
|> Lwt_stream.map (Format.asprintf "%a" out)
153-
|> Cohttp_lwt.Body.of_stream
151+
Ocsigen_response.Body.make Cohttp.Transfer.Unknown (fun write ->
152+
Lwt_list.iter_s (fun x -> write (Format.asprintf "%a" out x)) l)
154153

155154
let send ?options:_ ?charset ?code ?content_type ?headers c =
156155
let status = Eliom_lib.Option.map Cohttp.Code.status_of_code code
@@ -183,7 +182,7 @@ module String_base = struct
183182

184183
let send ?options ?charset ?code ?content_type:_ ?headers (c, content_type) =
185184
let status = Eliom_lib.Option.map Cohttp.Code.status_of_code code
186-
and body = Cohttp_lwt.Body.of_string c
185+
and body = Ocsigen_response.Body.of_string c
187186
and headers = add_cache_header options (Ocsigen_header.of_option headers) in
188187
result_of_content ?charset ?status ~content_type ~headers body
189188
end
@@ -258,7 +257,7 @@ module Action_base = struct
258257
| _ -> headers
259258
and status = Cohttp.Code.status_of_code code in
260259
result_of_content ?charset ?content_type ~headers ~status
261-
Cohttp_lwt.Body.empty
260+
Ocsigen_response.Body.empty
262261
| `Reload -> (
263262
(* It is an action, we reload the page. To do that, we retry
264263
without POST params.
@@ -358,7 +357,7 @@ module Unit_base = struct
358357
let send ?options:_ ?charset ?(code = 204) ?content_type ?headers _content =
359358
let status = Cohttp.Code.status_of_code code in
360359
result_of_content ?charset ?content_type ?headers ~status
361-
Cohttp_lwt.Body.empty
360+
Ocsigen_response.Body.empty
362361
end
363362

364363
module Unit = Eliom_mkreg.Make (Unit_base)
@@ -382,7 +381,7 @@ module Any_base = struct
382381
(result : 'a kind)
383382
=
384383
let result = Result_types.cast_kind result in
385-
let cohttp_response = fst (Ocsigen_response.to_cohttp result) in
384+
let cohttp_response = Ocsigen_response.response result in
386385
let headers =
387386
headers_with_content_type ?charset ?content_type
388387
(Cohttp.Response.headers cohttp_response)
@@ -442,15 +441,15 @@ module File_base = struct
442441
raise Eliom_common.Eliom_404
443442
with
444443
| Ocsigen_local_files.RFile fname ->
445-
let* response, body =
444+
let* res =
446445
let headers =
447446
Ocsigen_header.of_option headers
448447
|> add_cache_header options
449448
|> headers_with_content_type ?charset ?content_type
450449
in
451450
Cohttp_lwt_unix.Server.respond_file ~headers ~fname ()
452451
in
453-
Lwt.return (Ocsigen_response.make ~body response)
452+
Lwt.return (Ocsigen_response.of_cohttp res)
454453
| Ocsigen_local_files.RDir _ ->
455454
(* FIXME COHTTP TRANSITION: implement directories *)
456455
raise Ocsigen_local_files.Failed_404
@@ -1154,7 +1153,8 @@ module App_base (App_param : Eliom_registration_sigs.APP_PARAM) = struct
11541153
(match sp.Eliom_common.sp_client_appl_name, options.do_not_launch with
11551154
| None, true -> remove_eliom_scripts content
11561155
| _ -> add_eliom_scripts ~sp content)
1157-
>|= fun body -> Cohttp_lwt.Body.of_string (Format.asprintf "%a" out body)
1156+
>|= fun body ->
1157+
Ocsigen_response.Body.of_string (Format.asprintf "%a" out body)
11581158
in
11591159
let headers =
11601160
let h = Ocsigen_header.of_option headers in
@@ -1303,7 +1303,7 @@ module String_redirection_base = struct
13031303
in
13041304
let headers = Cohttp.Header.replace headers header_id uri in
13051305
result_of_content ?charset ?content_type ~status ~headers
1306-
(Cohttp.Body.empty :> Cohttp_lwt.Body.t)
1306+
Ocsigen_response.Body.empty
13071307
end
13081308

13091309
module String_redirection = Eliom_mkreg.Make (String_redirection_base)
@@ -1369,7 +1369,7 @@ module Redirection_base = struct
13691369
uri
13701370
in
13711371
result_of_content ?charset ?content_type ~status ~headers
1372-
(Cohttp.Body.empty :> Cohttp_lwt.Body.t)
1372+
Ocsigen_response.Body.empty
13731373
| true, Some anr ->
13741374
let headers =
13751375
Cohttp.Header.replace headers Eliom_common_base.appl_name_header_name
@@ -1394,7 +1394,7 @@ module Redirection_base = struct
13941394
uri
13951395
in
13961396
result_of_content ?charset ?content_type ~status:`No_content ~headers
1397-
(Cohttp.Body.empty :> Cohttp_lwt.Body.t)
1397+
Ocsigen_response.Body.empty
13981398
end
13991399

14001400
module Redirection = struct

src/lib/server/eliommod_pagegen.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ let out =
3333
Eliom_content_core.Html.Printer.pp ~encode ()
3434

3535
let make_response ?headers ~status body =
36-
let body = Cohttp_lwt.Body.of_string (Format.asprintf "%a" out body)
36+
let body = Ocsigen_response.Body.of_string (Format.asprintf "%a" out body)
3737
and response =
3838
let headers = headers_with_content_type headers in
3939
Cohttp.Response.make ~status ~headers ()
@@ -288,7 +288,7 @@ let gen_req_not_found ~is_eliom_extension ~sitedata ~previous_extension_err ~req
288288
Lwt.catch
289289
(fun () ->
290290
let* res = execute now genfun info sitedata in
291-
let response, _ = Ocsigen_response.to_cohttp res
291+
let response = Ocsigen_response.response res
292292
and all_user_cookies = Ocsigen_response.cookies res in
293293
let* cookies =
294294
Eliommod_cookies.compute_cookies_to_send sitedata all_cookie_info

0 commit comments

Comments
 (0)