Skip to content

Commit

Permalink
should send 100 Continue before 101 Switching Protocols when both Upg…
Browse files Browse the repository at this point in the history
…rade and Expect headers are present
  • Loading branch information
varshith257 committed Sep 24, 2024
1 parent 60bcf9b commit 414e317
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions zio-http/jvm/src/test/scala/zio/http/ServerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -520,17 +520,22 @@ object ServerSpec extends RoutesRunnableSpec {
} +
test("should send 100 Continue before 101 Switching Protocols when both Upgrade and Expect headers are present") {
val upgradeRoute = Method.GET / "upgrade" -> Handler.fromZIO {
ZIO.succeed(Response.switchingProtocols.withUpgrade("https"))
ZIO.succeed(
Response
.status(Status.SwitchingProtocols)
.addHeader(Header.Upgrade.withValue("https"))
.addHeader(Header.Connection.Upgrade),
)
}

val app = Routes(upgradeRoute)

// Build request with both Expect: 100-continue and Upgrade headers
val request = Request
.get("/upgrade")
.addHeader(Header.Expect(Header.Expect.Continue))
.addHeader(Header.Connection("upgrade"))
.addHeader(Header.Upgrade("https"))
.addHeader(Header.Expect.Continue)
.addHeader(Header.Connection.Upgrade)
.addHeader(Header.Upgrade.withValue("https"))

for {
response <- app.runZIO(request)
Expand Down

0 comments on commit 414e317

Please sign in to comment.