Intelligent way to parse HTTP header fields in Objective-C

I programmed for Android with Java, and its standard library has the Header and HeaderElement classes, through which you can parse HTTP headers in an intelligent manner. This is very useful because avoid the user analyzing the values โ€‹โ€‹of the headers (which can be different and complex).

These are their official documentation pages, the meaning of the methods is clear:
http://developer.android.com/reference/org/apache/http/Header.html http://developer.android.com/reference/org/apache/http/HeaderElement.html

Is there something similar for iOS in Objective-C? If I get a response (entered as NSHTTPURLResponse), do I need to manually process its header fields?

I ask about this because the only method I see to get the NSHTTPURLResponse message header is

- (NSDictionary *)allHeaderFields 

which simply returns a dictionary with NSString objects as values.

EDIT, added example

If you take, for example, the Cache-Control response header, it can have the following syntax:

 "public" | "private" [ "=" <"> 1#field-name <"> ] | "no-cache" [ "=" <"> 1#field-name <"> ] | "no-store" | "no-transform" | "must-revalidate" | "proxy-revalidate" | "max-age" "=" delta-seconds | "s-maxage" "=" delta-seconds | cache-extension 

Where

 [] means optional 1# means one ore more 

you understand that it can be difficult to parse the headers manually.

+4
source share

All Articles