views:

21

answers:

1

I'm making an iPhone application that requests JSON from Heroku.

  1. Am I getting a gzipped response? And, does the iPhone automatically unzip gzipped responses, or do you have to program that in? I'm using NSURLConnection asynchronously (with the delegate protocol) as described in the Xcode docs.

    When I do:

    curl -I http://acani.heroku.com/users/4c96ee4f1467281352000049/1234/50/50
    

    I get:

    HTTP/1.1 200 OK
    Server: nginx/0.7.67
    Date: Sun, 17 Oct 2010 16:27:25 GMT
    Content-Type: application/json
    Connection: keep-alive
    Content-Length: 11532
    X-Varnish: 2314841869
    Age: 0
    Via: 1.1 varnish
    
  2. I'm also using the Zimt WebSocket code with AsyncSocket for chat. The chat server is Node.js. Should I be gzipping each chat message? Or is that done automatically?

  3. I wonder, to reduce bandwidth, does Twitter gzip your tweets (with JavaScript on the web, or Objective-C on the iPhone) before they are sent to Twitter?

Thanks!

Matt

+1  A: 

To detect if a response is compressed or not, you need to look for a Content-Encoding header. It can be set to either gzip, compress, or deflate. See RFC 2616 Section 3.5 for more details.

Remy Lebeau - TeamB
Thanks. That's good to know. Now, how do I tell heroku to gzip for Sinatra?
MattDiPasquale
An HTTP server is not allowed to compress a response unless the client's request indicates that compression is supported. This is done via the `Accept-Encoding` request header, which specifies a comma-separated list of encodings that the client recognizes. The server can then pick one of them and specify in the `Content-Encoding` response header.
Remy Lebeau - TeamB