Guarantee JSON Response

14 views
Skip to first unread message

Asaf Peleg

unread,
May 13, 2016, 2:50:37 AM5/13/16
to spray.io User List

is there a way to guarantee that spray will always return a json response.  I found through testing that sending a very large or negative content-length results in a canned plain text response back from spray?


Logs show this : [WARN] [05/12/2016 17:14:28.690] [on-spray-can-akka.actor.default-dispatcher-9] [akka://on-spray-can/user/IO-HTTP/listener-0/3] Illegal request, responding with status '400 Bad Request': Illegal `Content-Length` header value


Response is: Illegal `Content-Length` header value

Age Mooij

unread,
May 23, 2016, 5:41:45 AM5/23/16
to spray...@googlegroups.com
Hi Asaf

The default rejection handler and exception handler in Spray will produce plain text output. If you want those to produce JSON, you will need to write custom versions of those. 

Some doc links:


Some examples of people who have wrapped the default rejection handler in JSON:



Hope this helps
Age


--
You received this message because you are subscribed to the Google Groups "spray.io User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spray-user+...@googlegroups.com.
Visit this group at https://groups.google.com/group/spray-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/spray-user/3b10f233-bbf7-496d-a82d-1a27668a8137%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages