Skip to content

Commit

Permalink
content_length_1XX_204
Browse files Browse the repository at this point in the history
  • Loading branch information
varshith257 committed Sep 24, 2024
1 parent d358348 commit 7abba9e
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions zio-http/jvm/src/test/scala/zio/http/ServerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 7abba9e

Please sign in to comment.