Reputation: 4123
I have this route:
path("rus") {
complete("Привет!")
}
When i go /rus with browser (chrome) i get this output:
"Привет!"
Why? Response headers are:
HTTP/1.1 200 OK
Server: akka-http/2.4.10
Date: Mon, 10 Oct 2016 22:31:53 GMT
Content-Type: application/json
Content-Length: 15
I used to use spray but now i want akka http, i didn't face an issue like this one.
When i curl this path i get normal output
$ curl http://localhost:9010/rus
"Привет!"
I see that response header 'Content-Type' shoud be 'application/json;charset=utf-8' but charset is missing...
Upvotes: 4
Views: 2547
Reputation: 8367
Unfortunately, this is a bug in chromium. The charset
parameter must be ignored for the application/json
content-type according to its IANA registration:
Note: No "charset" parameter is defined for this registration. Adding one really has no effect on compliant recipients.
Upvotes: 5
Reputation: 4123
I found method withParams. Now it works
HttpEntity(ContentType(MediaTypes.`application/json`.withParams(Map("charset" -> "utf-8"))), "Привет".getBytes("UTF-8"))
Upvotes: 5