I'm using RestKit to load a gzipped JSON with RKRequest:
RKRequest* request = [[RKClient sharedClient] requestWithResourcePath:urlString delegate:self];
[request send];
but I receive a status 406. When using AsiHttpRequest everything works, the response gets unzipped and I can work with the JSON. When I turn off gzip on server the RKRequest works.
What is wrong? I found no way to tell RKRequest, that the response will be zipped. Any ideas?
EDIT:
It is strange. Sometimes I get
Headers: {
Connection = "Keep-Alive";
"Content-Length" = 14;
"Content-Type" = "text/html; charset=UTF-8";
Date = "Fri, 16 Mar 2012 13:44:16 GMT";
"Keep-Alive" = "timeout=2, max=500";
Server = Apache;
"X-Powered-By" = "Servlet/2.5 JSP/2.1";
}
and sometimes I get application/gzip which is handled correct. My problem is why I get "Content-Type" = "text/html; charset=UTF-8"; sometimes.
And the same request opened in Safari results in a gzip-response always.
Can you post what's in your headers using an HTTP Proxy (like Charles)?
You may need to modify your "request headers" in the post call.
Make sure your firewall is able to accept POST calls. This might be an https issue.
EDIT:
You may need to configure your server to always return the response as a GZIP and DEFLATE based on the extension type. This is based on here (http://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/).
Example:
# compress json format in .htaccess (for apache servers):
AddOutputFilterByType DEFLATE application/json
You can find the 'mod_deflate' documentation here (http://httpd.apache.org/docs/2.0/mod/mod_deflate.html)
If you can post the outgoing headers, that would also be useful, as they should include:
Accept-Encoding: gzip, deflate
Similar issues
https://groups.google.com/forum/?fromgroups#!topic/restkit/Xo84PH1l5kM
Weird "406 not acceptable" error
https://serverfault.com/questions/183843/content-length-not-sent-when-gzip-compression-enabled-in-apache
EDIT:
Make sure you also do this:
[[RKClient sharedClient] setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"];
or this
[[RKClient sharedClient] setValue:@"gzip, deflate" forHTTPHeaderField:@"Accept-Encoding"];
This should set the value of your header to accept "gzip" for encoding the response. I noticed these github issues: