App Engine接受编码 [英] App Engine Accept-Encoding

查看:208
本文介绍了App Engine接受编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在APP引擎API中提到,如果请求带有Accept-Encoding set,那么它会自动压缩响应。



但是当我查看请求时,标题不在那里。但在浏览器中,它已被设置。当我尝试显式设置标题(使用 jQuery ajax 函数)时,会出现一条消息:

 拒绝设置不安全的标题Accept-Encoding

但是,在本地主机上工作时不会发生这种情况 - 请求具有Accept-Encoding标头。这只在发布后才会发生。但不允许明确地设置Accept-Encoding。

我到处搜索,但找不到问题的解释。如果有人能解释,这将是非常有帮助的......

解决方案

您有两个不同的问题: b


  1. App Engine不会压缩回复。 GAE使用许多因素来确定是否需要压缩响应。决定时需要考虑内容类型和用户代理。查看Nick Johnson(来自GAE团队)的答案。 jQuery拒绝设置Accept-Encoding标题。

  2. 请注意,这是一个jQuery问题,与GAE无关。看到这个:是否有可能强制jQuery使用启用了gzip / deflate的URL进行AJAX调用?


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...

解决方案

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?

这篇关于App Engine接受编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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