raboof commented on code in PR #584:
URL: https://github.com/apache/pekko-http/pull/584#discussion_r1747145701
##########
http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/MarshallingDirectivesSpec.scala:
##########
@@ -275,4 +275,23 @@ class MarshallingDirectivesSpec extends RoutingSpec with
Inside {
}
}
}
+
+ "The marshalling infrastructure for text" should {
+ val foo = "Hällö"
+ "render text with UTF-8 encoding if no `Accept-Charset` request header is
present" in {
+ Get() ~> complete(foo) ~> check {
+ responseEntity shouldEqual HttpEntity(ContentType(`text/plain`,
`UTF-8`), foo)
+ }
+ }
+ "render text with requested encoding if an `Accept-Charset` request header
requests a non-UTF-8 encoding" in {
+ Get() ~> `Accept-Charset`(`ISO-8859-1`) ~> complete(foo) ~> check {
+ responseEntity shouldEqual HttpEntity(ContentType(`text/plain`,
`ISO-8859-1`), foo)
+ }
+ }
+ "render text with UTF-8 encoding if an `Accept-Charset` request header
requests an unknown encoding" in {
+ Get() ~> `Accept-Charset`(HttpCharset("unknown")(Nil)) ~> complete(foo)
~> check {
+ responseEntity shouldEqual HttpEntity(ContentType(`text/plain`,
`UTF-8`), foo)
+ }
+ }
Review Comment:
what I meant is, when the route does `complete(some_unicode_string)`, and
the marshalling logic results in a `Content-Type: text/plain;
charset=ISO-8859-1` header, that response seems wrong: the header promises the
body will be in ISO-8859-1, but the body is actually in unicode. I think it
would make more sense to make sure we produce a `Content-Type: text/plain;
charset=UTF-8` header unless the developer explicitly marked the response as
being in a different charset.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]