我正在制作一个从Heroku请求JSON的iPhone应用程序。
我得到了一个gzipped的回复吗?
并且,iPhone会自动进行
解压缩gzipped响应,或者你
必须编程吗?我正在使用
NSURLConnection
异步
(使用委托协议)as
在Xcode文档中描述。
当我这样做时:
curl -I http://acani.heroku.com/users/4c96ee4f1467281352000049/1234/50/50
我明白了:
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
我也在使用带有AsyncSocket的Zimt WebSocket代码进行聊天。聊天服务器是Node.js.我应该抓住每条聊天消息吗?或者这是自动完成的吗?
我想知道,为了减少带宽,Twitter是否会在发送到推特之前将你的推文(在网上使用JavaScript或在iPhone上使用Objective-C)gzip?
谢谢!
马特
答案 0 :(得分:3)
要检测响应是否已压缩,您需要查找Content-Encoding
标头。它可以设置为gzip
,compress
或deflate
。有关详细信息,请参阅RFC 2616第3.5节。
答案 1 :(得分:0)
请不要将RFС用于任何与标准相关的常数。我想建议改用iana registries。如果您需要Content-Encoding
,则可以使用http-parameters.xml。
HTTP内容编码注册表:
aes128gcm
br
compress
deflate
exi
gzip
identity
pack200-gzip
x-compress
x-gzip
zstd
您可以提供更好的解决方案:
#!/bin/sh
torsocks wget \
--recursive \
--domains "iana.org" \
--no-parent "https://www.iana.org/protocols" \
--accept-regex "https://www.iana.org/(assignments|protocols)/.*"
git init
./download.sh
git add . && git commit
您需要从标准中找到任何常量吗?只是grep iana
文件夹。
您是否需要熟悉所有最近的更改? download.sh && git diff
。