From 7abba9eba8624a17f34a727f94c95116fb746561 Mon Sep 17 00:00:00 2001 From: Vamshi Maskuri <117595548+varshith257@users.noreply.github.com> Date: Tue, 24 Sep 2024 08:15:56 +0530 Subject: [PATCH] content_length_1XX_204 --- .../src/test/scala/zio/http/ServerSpec.scala | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/zio-http/jvm/src/test/scala/zio/http/ServerSpec.scala b/zio-http/jvm/src/test/scala/zio/http/ServerSpec.scala index 3408ef9b26..ec4c9a37fb 100644 --- a/zio-http/jvm/src/test/scala/zio/http/ServerSpec.scala +++ b/zio-http/jvm/src/test/scala/zio/http/ServerSpec.scala @@ -578,13 +578,19 @@ object ServerSpec extends RoutesRunnableSpec { } } + test("should not include Content-Length header for 1xx responses") { - val route = Method.GET / "info" -> Handler.fromResponse(Response(status = Status.Continue)) - val app = Routes(route) + val statusCodes = List(Status.Continue, Status.SwitchingProtocols, Status.Processing) // Add more if needed - val request = Request.get("/info") - for { - response <- app.runZIO(request) - } yield assertTrue(!response.headers.contains(Header.ContentLength.name)) + ZIO + .foreach(statusCodes) { status => + val route = Method.GET / "info" -> Handler.fromResponse(Response(status = status)) + val app = Routes(route) + + val request = Request.get("/info") + for { + response <- app.runZIO(request) + } yield assertTrue(!response.headers.contains(Header.ContentLength.name)) + } + .map(assertTrue(_)) } + test("should not include Content-Length header for 204 No Content responses") { val route = Method.GET / "no-content" -> Handler.fromResponse(Response(status = Status.NoContent))