"Transfer-encoding: chunked" request handling


I’m trying to add Play framework support to Asity, an HTTP/WebSocket abstraction layer for various web frameworks on the JVM. We released the first beta this week — https://asity.cettia.io/#play-2 but couldn’t solve the following problems about “Transfer-encoding: chunked” request handling. It would be nice if you could give me some hints.

  1. How to read request body by chunk.

Assumes that the client opens a “Transfer-encoding: chunked” request and writes a small chunk to the body per second. What I expect is that an action in the controller receives a chunk every time the client writes it, but Play seemed to wait till the client finishes writing the body and give an action the whole body when finished. How can the action read a new chunk in a request body every time the client writes it?

  1. How to detect disconnection.

If the client opens some request and aborts it for some reason so the underlying TCP connection is broken, how can an action detect it?

Thanks in advance.