From 7fee50064e3d7233ed49175e24ca1c79ddaeb79a Mon Sep 17 00:00:00 2001 From: Vamshi Maskuri <117595548+varshith257@users.noreply.github.com> Date: Tue, 24 Sep 2024 16:02:32 +0530 Subject: [PATCH] Transfer Encoding Header --- .../src/test/scala/zio/http/ServerSpec.scala | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) 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 d3882a04af..372e527a5d 100644 --- a/zio-http/jvm/src/test/scala/zio/http/ServerSpec.scala +++ b/zio-http/jvm/src/test/scala/zio/http/ServerSpec.scala @@ -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(