我已经将我的Tomcat 6.0配置为通过AWS EC2安装在Linux服务器上,以压缩大型JSON对象响应(大小约为54k) - 但由于某种原因它不会压缩它。
/usr/share/tomcat6/conf/server.xml中的连接器定义 -
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000" compression="force"
compressableMimeType="text/html,text/xml,text/plain,application/javascript,application/json,text/javascript,text/json"
redirectPort="8443" />
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="200" scheme="https" secure="true" compression="force"
compressableMimeType="text/html,text/xml,text/plain,application/javascript,application/json,text/javascript,text/json"
keystoreFile="/usr/share/tomcat6/conf/my.keystore" keystorePass="password"
clientAuth="false" sslProtocol="TLS" />
请求标头,接受gzip -
POST /mycommand HTTP/1.1
Host: my.host.com
Proxy-Connection: close
Accept-Encoding: gzip
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Content-Length: 431
响应标头,在Connector上配置MIME -
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: application/json;charset=UTF-8
Vary: Accept-Encoding
Date: Mon, 27 Aug 2012 20:19:05 GMT
Connection: close
Content-Length: 55565
我已尝试compressed="2048"
,同样的问题。
我在服务器上的命令方法是使用带有jackson JAR的Spring MVC来创建JSON响应 -
@RequestMapping(method=RequestMethod.POST, value="/mycommand")
public @ResponseBody BasicResponse doCommand(
...
}
有什么想法吗?
答案 0 :(得分:2)
好的,这很烦人......
事实证明,我用来监控所有通信的代理Burp Suite已经unpack gzip / deflate
进行了检查。
您必须完全向下滚动并取消选中它以接收压缩响应。
一旦删除,一切正常。