web-serviceshttpplayframeworkws-client

gzip request from Play Framework's WSClient


I'm trying to call a webservice using the WSClient API from Play Framework. The main issue is that I want to transfer huge JSON payloads (more than 2MB) without exceeding the maximal payload size.

To do so, I would like to compress the request using gzip (with the HTTP header Content-Encoding: gzip). In the documentation, the parameter play.ws.compressionEnabled is mentioned, but it only seems to enable WSResponse compression.

I have tried to manually compress the payload (using a GZipOutputStream) and to put the header Content-Encoding:gzip, but the server throws a io.netty.handler.codec.compression.DecompressionException : Unsupported compression method 191 in the GZIP header.

How could I correctly compress my request ?

Thanks in advance


Solution

  • Unfortunately I don't think you can compress the request (it is not supported by Netty, the underlying library). You can find more info in https://github.com/AsyncHttpClient/async-http-client/issues/93 and https://github.com/netty/netty/issues/2132