App Engine Accept-Encoding

2019-05-03 15:59发布

In the APP Engine API, it is mentioned that, if the request comes with "Accept-Encoding" set, then it will automatically compress the response.

But when I look at the request, the header is not there. but at the browser, it is set. when I try to explicitly set the header(with JQuery ajax function), there is a message:

 Refused to set unsafe header "Accept-Encoding"

But this situation is not occurring when working in local host - request has the "Accept-Encoding" header. this happens only after publishing. but not allowing to set the "Accept-Encoding" explicitly happens always.

I searched everywhere, but couldn't find a explanation to the problem. It would be really helpful if someone can explain...

2条回答
迷人小祖宗
2楼-- · 2019-05-03 16:08

I have a similar problem as in the HTTPRequest header, "Accept-Encoding" is null. As GAE has explained it looks for Accept-Encoding and User-Agent headers, if it wants to compress. but in my case there is no way the GAE can recognize whether to compress.

From the browser, then header is set, but in the request header, it is not.

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-05-03 16:19

You have two different problems:

  1. App Engine does not compress reply. GAE uses a number of factors to determine if response needs to be compressed. It takes content type and user agent into account when deciding. See the answer by Nick Johnson (from GAE team).

  2. jQuery refuses to set "Accept-Encoding" header. Note that this is a jQuery issue and has nothing to do with GAE. See this: Is it possible to force jQuery to make AJAX calls for URLs with gzip/deflate enabled?

查看更多
登录 后发表回答