Skip to content

Commit

Permalink
Return Content-Type for POST requests
Browse files Browse the repository at this point in the history
Previously `Content-Type` was not explicitly returned for POST requests.
This would result in errors being logged for javascript tracker in Firefox[1].
Now, the behavior is rolled back to previous where collector would return
`Content-Type` header for these requests.

Addresses [BCPF-1102] and [PDP-1110]

---

1 - https://bugzilla.mozilla.org/show_bug.cgi?id=884693
  • Loading branch information
peel committed Apr 10, 2024
1 parent df59504 commit 59438a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ class Service[F[_]: Sync](
case _ =>
Response[F](
status = Ok,
headers = headers,
headers = headers.put(`Content-Type`(MediaType.text.plain)),
body = Stream.emit("ok").through(fs2.text.utf8.encode)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,15 +535,16 @@ class ServiceSpec extends Specification {
res.headers shouldEqual testHeaders
}
"send back ok otherwise" in {
val headers = testHeaders.put(`Content-Type`(MediaType.text.plain))
val res = service.buildHttpResponse(
queryParams = Map.empty,
headers = testHeaders,
headers = headers,
redirect = false,
pixelExpected = false,
shouldBounce = false
)
res.status shouldEqual Status.Ok
res.headers shouldEqual testHeaders
res.headers shouldEqual headers
res.bodyText.compile.toList.unsafeRunSync() shouldEqual List("ok")
}
}
Expand All @@ -560,13 +561,14 @@ class ServiceSpec extends Specification {
res.body.compile.toList.unsafeRunSync().toArray shouldEqual Service.pixel
}
"send back ok otherwise" in {
val headers = testHeaders.put(`Content-Type`(MediaType.text.plain))
val res = service.buildUsualHttpResponse(
headers = testHeaders,
headers = headers,
pixelExpected = false,
shouldBounce = false
)
res.status shouldEqual Status.Ok
res.headers shouldEqual testHeaders
res.headers shouldEqual headers
res.bodyText.compile.toList.unsafeRunSync() shouldEqual List("ok")
}
}
Expand Down

0 comments on commit 59438a4

Please sign in to comment.