【问题标题】:How do I prevent GAE from ungzipping a gzipped xml feed?如何防止 GAE 解压缩 gzip 压缩的 xml 提要?
【发布时间】:2012-03-17 15:19:17
【问题描述】:

我在 GAE 上有一个脚本,它向合作伙伴请求 XML 提要,该提要通常为 40MB,但压缩后只有 5MB。 GAE 正在自动解压缩此内容并抛出响应太大的错误:

HTTP 响应过大:46677241。限制为:33554432。

脚本设置为解压缩响应本身。如何防止 GAE 妨碍和破坏?

这是我的伙伴的响应标头:

HTTP/1.0 200 OK
Expires: Wed, 27 Jun 2012 05:42:07 GMT
Cache-Control: max-age=10368000
Content-Type: application/x-gzip
Accept-Ranges: bytes
Last-Modified: Wed, 22 Feb 2012 11:06:09 GMT
Content-Length: 5263323
Date: Tue, 28 Feb 2012 05:42:07 GMT
Server: lighttpd
X-Cache: MISS from static01
X-Cache-Lookup: MISS from static01:80
Via: 1.0 static01:80 (squid)

【问题讨论】:

    标签: http google-app-engine cron gzip


    【解决方案1】:

    您合作伙伴的服务器很可能以纯 XML 响应,因为它认为 http-client 发送请求(即 GAE URL Fetch 服务)不支持 gzipping。因此出现“响应过大”错误。

    要宣布您确实想要接收 gzip 压缩的内容,您需要在使用 URL 获取服务时设置 Accept-Encoding: gzip 标头。

    【讨论】:

    • 获取的文件名实际上以“xml.gz”结尾。谢谢,不过,无论如何我都会将它添加到请求中,看看它是否有帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-02-12
    • 2015-07-14
    • 2021-11-30
    • 2015-02-06
    • 2012-09-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多