3

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.

  1. Can't I deflate the POST response? If yes, How and what am I missing here?
  2. Any other alternative?

Thanks.

Ashwin
  • 1,942
  • 4
  • 30
  • 59
  • Your question is a bit unclear. Are you attempting to write your own http server in C? I suspect that the server is returning content that isn't correctly gzip encoded. You can determine this using Fiddler. See my post here on how to do that: http://stackoverflow.com/questions/24490168/ungzip-csv-files-in-web-browser-with-javascript/24653466#24653466 – Shawn McGough Jul 09 '14 at 13:01

0 Answers0