在iPhone上处理eTags [英] Handling eTags on iPhone
问题描述
有什么想法如何在客户端处理eTag?我们计划在我们的应用程序中使用eTag,这些图像来自服务器。
对于什么是eTag,请参阅:
http://en.wikipedia.org/wiki/HTTP_ETag
您的学习起点...
NSMutableURLRequest
您可以为您的请求设置eTag值。
[self addValue:eTag forHTTPHeaderField:@ If-None-Match];
此请求可用于NSURLConnection。
NSURLConnectionDelegate
您的NSURLConnection代表有... ...
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
$ c $ p>
$ b b ...您的情况下的响应是 NSHTTPURLResponse
。
委托方法...
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
...当远程对象未被修改时接收状态代码304。如果远程对象被修改并且支持eTag,你可以在 [response allHeaderFields]
中找到它。
Any idea how to handle eTags at client side? We are planning to use eTags with images in our application which are coming from the server.
For what is eTag please see this:
http://en.wikipedia.org/wiki/HTTP_ETag
解决方案 Starting points for your study ...
NSMutableURLRequest
Here you can set eTag value for you request.
[self addValue:eTag forHTTPHeaderField:@"If-None-Match"];
This request is usable with NSURLConnection.
NSURLConnectionDelegate
Delegate of your NSURLConnection has method ...
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
... where response in your case is NSHTTPURLResponse
.
You should check response statusCode in another delegate's method ...
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
... status code 304 is received when remote object is not modified. If remote object is modified and eTag is supported, you can find it in [response allHeaderFields]
.
这篇关于在iPhone上处理eTags的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!