开发者

Ajax response is gzip compressed - Prototype, Firefox can't handle it

I'm trying to query a web service (with JavaScript, prototype). The server responds with XML, but compresses it; headers are set appropriately.

Under Safari 4, everything is fine. The response is decompressed and JavaScript can deal with the data.

Under Firefox 3.5.8, no data is returned to JavaScript!

Code:

     var req = new Ajax.Request(this.url, {
        asynchronous: false,
        contentType: 'text/xml',
        method: 'post',
        postBody: xmlString,
        onSuccess: function(t) {
            // debug, place response into textarea to show
            $('responseText').value = t.responseText;
        }
    });

This is the response, as I trace it on the network:

HTTP/1.1 200 OK.
Date: Fri, 05 Mar 2010 14:10:51 GMT.
Server: Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny6 with Suhosin-Patch.
X-Powered-By: PHP/5.2.6-1+lenny6.
Vary: Accept-Encoding.
Content-Encoding: gzip.
Content-Length: 2104.
Keep-Alive: timeout=15, max=100.
Connection: Keep-Alive.
Content-Type: text/xml.
.
............]s......W`.3...H&A.$.Q.^[.:....... (and so on ...)

Any idea why this is happening? What can I do about it?

I tried setting the 'Accept-Encodi开发者_运维问答ng' header in the request, can't get it working properly. Besides, the response can be rather large, meaning: it's good that it is compressed by the server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜