Skip to content

Commit

Permalink
Add tests for StreamedResponse to make sure its header's map is case …
Browse files Browse the repository at this point in the history
…insensitively

(cherry picked from commit f6bac89)
  • Loading branch information
mkurz authored and mergify[bot] committed Jul 8, 2024
1 parent 1f4f1d1 commit 820ca3c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ class AhcWSResponseSpec extends Specification with DefaultBodyReadables with Def
headers.contains("Bar") must beTrue
}

"get headers map which retrieves headers case insensitively (for streamed responses)" in {
val srcHeaders = Map("Foo" -> Seq("a"), "foo" -> Seq("b"), "FOO" -> Seq("b"), "Bar" -> Seq("baz"))
val response = new StreamedResponse(null, 200, "", null, srcHeaders, null, true)
val headers = response.headers
headers("foo") must_== Seq("a", "b", "b")
headers("BAR") must_== Seq("baz")
}

"get a single header" in {
val ahcResponse: AHCResponse = mock[AHCResponse]
val ahcHeaders = new DefaultHttpHeaders(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ class AhcWSResponseSpec extends Specification with DefaultBodyReadables with Def
headers.get("BAR").asScala must_== Seq("baz")
}

"get headers map which retrieves headers case insensitively (for streamed responses)" in {
val srcHeaders = Map("Foo" -> Seq("a"), "foo" -> Seq("b"), "FOO" -> Seq("b"), "Bar" -> Seq("baz"))
val response = new StreamedResponse(null, 200, "", null, srcHeaders, null, true)
val headers = response.getHeaders
headers.get("foo").asScala must_== Seq("a", "b", "b")
headers.get("BAR").asScala must_== Seq("baz")
}

"get a single header" in {
val srcResponse = mock[Response]
val srcHeaders = new DefaultHttpHeaders()
Expand Down

0 comments on commit 820ca3c

Please sign in to comment.