gzip压缩导致错误请求的空响应,否则工作正常 [英] gzip compression results in empty response on bad request, works fine otherwise

查看:158
本文介绍了gzip压缩导致错误请求的空响应,否则工作正常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有以下标题的angular从Web客户端执行HTTP POST请求:

I am doing a HTTP POST request from a web client using angular with the following header:

Accept-Encoding: gzip, deflate, br

服务器响应内容类型是application / json。当响应状态为200时,一切正常,我的响应有一个我可以从客户端看到的正文。但是,当响应状态为400时,响应主体根据客户端为空,但我确定我在服务器上填充它。此外,如果我从上面的请求标题中删除gzip(无论是否更改服务器端),那么即使有400响应状态,一切正常,换句话说,我可以从客户端看到响应主体。我在服务器端使用Spring运行Tomcat。

The server response content-type is application/json. When the response status is 200, everything works fine, my response has a body that I can see from the client. However, when the response status is 400, the response body is empty according to the client, but I am certain I am populating it on the server. Also, if I remove "gzip" from the request header above (no change server-side whatsoever), then everything works fine even with a 400 response status, in other words I can see the response body from the client. I'm running Tomcat with Spring on the server side.

看起来gzip似乎是我问题的原因,但我不明白为什么或如何修复它,任何帮助将不胜感激。

It really seems like gzip is the cause of my problem here, but I don't understand why or how to fix it, any help would be appreciated.

提前致谢。

推荐答案

我们弄清楚了,我们使用旧版本的ehcache-web库,因此使用的是GZipFilter,它没有为200以外的任何状态返回响应主体。升级到该库的2.0.4版本已修复问题。

We figured it out, we were using an old version of the ehcache-web library and thus its GZipFilter, which didn't return the response body for any status other than 200. Upgrading to version 2.0.4 of that library fixed the issue.

这篇关于gzip压缩导致错误请求的空响应,否则工作正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆