来自 Play Framework 的 WSClient 的 gzip 请求



我正在尝试使用Play Framework中的WSClient API调用Web服务。主要问题是我想转移巨大的JSON有效载荷(超过2MB),而不会超过最大有效载荷大小。

为此,我想使用GZIP(使用HTTP标头Content-Encoding: gzip)来压缩请求。在文档中,提到了参数play.ws.compressionEnabled,但似乎仅启用WSRESPONSE压缩。

我试图手动压缩有效载荷(使用gzipoutputstream)并放置标题Content-Encoding:gzip,但服务器抛出io.netty.handler.codec.compression.DecompressionException : Unsupported compression method 191 in the GZIP header

如何正确压缩我的请求?

预先感谢

不幸的是,我认为您不能压缩请求(基础库Netty不支持它)。您可以在https://github.com/asynchttpclient/async-http-client/issues/93和https://github.com/netty/netty/netty/issues/2132

中找到更多信息。

最新更新