Using custom body parser with the embedded Play server

Hello,

I am using Play embedded server to proxy requests and responses to some other remote HTTP APIs.
While I can perfectly stream responses using the RoutingDsl.routingAsync() method, I have not figured out a way to stream requests body to the remote API. Every time the request body gets loaded entirely in memory as a String .

I found that what I am looking for is body parsers: https://www.playframework.com/documentation/2.8.x/JavaBodyParsers
That is great, but I cannot find a way to configure my body parser using the embedded Play server.

I already tried to override the BuiltInComponents used by the RoutingDsl, but I ran into a dead end:

  • I can override the BuiltInComponents.defaultBodyParser() method to customize the PlayBodyParsers
  • But the PlayBodyParsers does not let me override anything that looks like a body parser provider (I was confident in overriding the PlayBodyParsers.config() method, but that is just a Scala case class to customize some buffers :cry:)

Do you have some ideas on how I can customize the body parser for the Play embedded server?

Note that I am using Play 2.8 for Java.

Thank you a lot for your help.
Aurélien