From 09c4f9618d4b3ed3a0019420fd7b6e19405ba132 Mon Sep 17 00:00:00 2001 From: "Sean T. Allen" Date: Sun, 4 Feb 2024 15:23:18 +0000 Subject: [PATCH] Always set content-length Not setting it makes some clients unhappy. --- .release-notes/set-content-length.md | 3 +++ http_server/_test_reponse.pony | 2 +- http_server/response.pony | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 .release-notes/set-content-length.md diff --git a/.release-notes/set-content-length.md b/.release-notes/set-content-length.md new file mode 100644 index 0000000..f3309c4 --- /dev/null +++ b/.release-notes/set-content-length.md @@ -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. diff --git a/http_server/_test_reponse.pony b/http_server/_test_reponse.pony index 1a075b9..511029e 100644 --- a/http_server/_test_reponse.pony +++ b/http_server/_test_reponse.pony @@ -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) diff --git a/http_server/response.pony b/http_server/response.pony index 0432370..43cfdc7 100644 --- a/http_server/response.pony +++ b/http_server/response.pony @@ -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