I am trying to compress JSON response content for my ajax request. The server is a very basic http server written in C.
The browser is able to send the required Content-Encoding
headers in the request to the server.
The request header looks like this:
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding:gzip,deflate,sdch
Content-Type:application/x-www-form-urlencoded
Origin:http://127.0.0.1:1234
Referer:http://127.0.0.1:1234/index.html
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.71 Safari/537.36
X-Requested-With:XMLHttpRequest
Since, my server can see that there is Accept-Encoding:gzip,deflate,sdch
methods available, it deflates to gzip
and also sets the response headers to
Content-Encoding:gzip
alone with these information
Cache-Control:no-cache
charset:UTF8
Content-Length:134
Content-Type:text/plain
Expires:0
Pragma:no-cache
(Note: it includes Content-Encoding:gzip
)
After all these, the browser shows "failed" in the network tab for this request.
The same compression works really well with GET
requests.
- Can't I deflate the
POST
response? If yes, How and what am I missing here? - Any other alternative?
Thanks.