1

i am working on java with Netbeans IDE and glassfish 3.1.2 i have created in rest services using jaxrs. when request from client is made ,i need to send json data in compressed format.to do this i have enabled the compression in glassfish as shown the following picture

enter image description here

but response got from the server is not compressed using gzip. it is receiving as normal json data. what should i do to overcome this issue

4

2 回答 2

1

This is a solution for GF 3.1.2.2.

Responses to HTTP requests in version 1.0 are not compressed. You must send your requests in HTTP 1.1 to get gzipped responses from your glassfish server.

More over, you must add the header "Accept-Encoding: gzip" in your http requests.

于 2013-04-17T14:02:10.860 回答
0

要获得压缩响应,您需要让双方同意使用它。您已将 GlassFish 配置为发送压缩响应。我可以从图片中看出这一点。

您需要确保您对服务的请求告诉 GlassFish 它可以接受压缩响应。您通常通过将以下标头添加到 HTTP 请求来执行此操作:Accept-Encoding。您可以阅读定义 HTTP 1.1 请求标头的 RFC 文档中的标头

您还可以通过阅读有关 Accept-Encoding 的 SO 问题获得很多信息。

于 2013-04-09T14:52:31.463 回答