Work around dream-encoding footgun #13
2 changed files with 14 additions and 2 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
2
lib/dune
2
lib/dune
|
@ -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))
|
||||||
|
|
Loading…
Reference in a new issue