On 05/05/17 18:42, Alex Cozzi wrote:

funny, I was looking into this yesterday!
I am by no means an expert, but I think that what it is happening is the
following:
application/json implies UTF-8: if you look at the MediaType class from
akka http you se the declaration:

I believe you are correct, http://www.ietf.org/rfc/rfc4627.txt says:

3.  Encoding
JSON text SHALL be encoded in Unicode.  The default encoding is UTF-8.

so an explicit MIME type isn't required if the content is UTF-8 - but other JSON frameworks do often seem to include the UTF-8 charset.

As far as I know there's no "proper" way of forcing the addition of the charset to the application/json content type in Akka-HTTP but it is possible to hack around it:

val ct = ContentType(MediaType.custom("application/json", false).asInstanceOf[MediaType.WithOpenCharset], HttpCharset.custom("utf-8"))

--
Alan Burlison
--

--
     Read the docs: http://akka.io/docs/
     Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
     Search the archives: https://groups.google.com/group/akka-user
--- You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to