Skip to content

Commit

Permalink
Always set content-length
Browse files Browse the repository at this point in the history
Not setting it makes some clients unhappy.
  • Loading branch information
SeanTAllen committed Feb 4, 2024
1 parent 0802950 commit 09c4f96
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .release-notes/set-content-length.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Always set Content-Length

There was a bug where the Content-Length header could end up not being sent. This would cause many clients (such as curl) to hang.
2 changes: 1 addition & 1 deletion http_server/_test_reponse.pony
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class \nodoc\ iso _BuildableResponseTest is UnitTest

fun apply(h: TestHelper) ? =>
let without_length = BuildableResponse()
h.assert_is[None](None, without_length.header("Content-Length") as None)
h.assert_is[String]("0", without_length.header("Content-Length") as String)

let with_length = BuildableResponse(where content_length' = 42)
h.assert_eq[String]("42", with_length.header("Content-Length") as String)
4 changes: 2 additions & 2 deletions http_server/response.pony
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ class val BuildableResponse is (Response & ByteSeqIter)
match cl
| let clu: USize =>
set_header("Content-Length", cl.string())
// | None =>
// TODO: drop header
| None =>
set_header("Content-Length", "0")
end
this

Expand Down

0 comments on commit 09c4f96

Please sign in to comment.