Work around dream-encoding footgun #13

Merged
reynir merged 1 commit from fix-dream-encode into main 2025-01-24 13:21:18 +00:00
2 changed files with 14 additions and 2 deletions

View file

@ -797,7 +797,19 @@ let error_template error _debug_info suggested_response =
in in
Dream.set_header suggested_response "Content-Type" Dream.text_html; Dream.set_header suggested_response "Content-Type" Dream.text_html;
Dream.set_body suggested_response @@ string_of_html html; Dream.set_body suggested_response @@ string_of_html html;
Lwt.return suggested_response (* NOTE: this does the same job as the dream-encoding middleware;
the middleware is not triggered in error templates *)
let preferred_algorithm =
Option.bind error.request
Dream_encoding.preferred_content_encoding
in
begin match preferred_algorithm with
| Some algorithm ->
let+ body = Dream.body suggested_response in
Dream_encoding.with_encoded_body body ~algorithm suggested_response
| None ->
Lwt.return suggested_response
end
| _ -> | _ ->
Lwt.return suggested_response Lwt.return suggested_response

View file

@ -2,4 +2,4 @@
(name builder_web) (name builder_web)
(libraries builder builder_db dream tyxml bos duration ohex caqti-lwt (libraries builder builder_db dream tyxml bos duration ohex caqti-lwt
opamdiff ptime.clock.os cmarkit tar tar.gz tar-unix owee solo5-elftool decompress.de opamdiff ptime.clock.os cmarkit tar tar.gz tar-unix owee solo5-elftool decompress.de
decompress.gz uri digestif)) decompress.gz uri digestif dream-encoding))