Skip to content

Conversation

@Julow
Copy link
Contributor

@Julow Julow commented Jul 18, 2025

Ocsigen_response carries a Cohttp.Response.t and a body and both of them carry a transfer-encoding.
The problem is that the Cohttp.Response.t is often constructed with a default value for the transfer encoding that takes precedence over the encoding of the body.

This changes Ocsigen_response.make to remove the header if it is equal to the default value. The correct way to specify the encoding is while constructing the Body.t value. Setting the header with Ocsigen_response.add_header is also supported.

This bug could materialize with pages that never finish loading or with trimmed content.
Especially in Eliom, where Cohttp.Response.make is often called without the ~encoding argument.

This bug was introduced in #260 while introducing the Body.t type.

`Ocsigen_response` carries a `Cohttp.Response.t` and a `body` and both
of them carry a `transfer-encoding`.
The problem is that the `Cohttp.Response.t` is often constructed with a
default value for the transfer encoding that takes precedence over the
encoding of the body.

This changes `Ocsigen_response.make` to remove the header if it is equal
to the default value. The correct way to specify the encoding is while
constructing the `Body.t` value. Setting the header with
`Ocsigen_response.add_header` is also supported.

This bug could materialize with pages that never finish loading or with
trimmed content.
Especially in Eliom, where `Cohttp.Response.make` is often called
without the `~encoding` argument.
@balat balat merged commit a3be37c into ocsigen:master Jul 23, 2025
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants