Skip to content

Commit

Permalink
Transfer Encoding Header
Browse files Browse the repository at this point in the history
  • Loading branch information
varshith257 committed Sep 24, 2024
1 parent 2849009 commit 7fee500
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions zio-http/jvm/src/test/scala/zio/http/ServerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,27 @@ object ServerSpec extends RoutesRunnableSpec {
!response.headers.contains(Header.ContentLength.name),
)
} +
test("should not include Transfer-Encoding header for 2XX CONNECT responses") {
val app = Routes(
Method.CONNECT / "" -> Handler.fromResponse(
Response.status(Status.Ok),
),
)

val decodedUrl = URL.decode("https://example.com:443")

val request = decodedUrl match {
case Right(url) => Request(method = Method.CONNECT, url = url)
case Left(_) => throw new RuntimeException("Failed to decode the URL")
}

for {
response <- app.runZIO(request)
} yield assertTrue(
response.status == Status.Ok,
!response.headers.contains(Header.TransferEncoding.name),
)
} +
test("should send Upgrade header with 426 Upgrade Required response") {
val app = Routes(
Method.GET / "test" -> Handler.fromResponse(
Expand Down

0 comments on commit 7fee500

Please sign in to comment.