Apple's iPhone: Accessing HTTP Headers from an NSURLRequest
64
Programming the iPhone from Apple
Using NSURLRequest to send the HTTP Headers that Accompanied a Query Response
One of the more quirky programming (coding) tasks with the Apple iPhone relates to headers for http connections, and although not difficult, can be quite frustrating if the syntax isn't correct.
In the NSHTTPURLResponse class, the headers for an HTTP connection are included. By sending the allHeaderFields message with the NSHTTPURLResponse variable, you can easily get the headers out as NSDictionary.
Although synchronous requests are problematic due to blocking issues, populating an NSHTTPURLResponse in this manner is fairly straightforward:
In the case of an asynchronous request, the code structure is more complicated. When using the callback connection:didReceiveResponse:, the second parameter passed is NSURLResponse. You can send it to an NSHTTPURLResponse like so:
iPhone Accessories
|
5-Pack Premium Reusable LCD Screen Protector with Lint Cleaning Cloth for Apple iPhone 3G 8GB 16GB [Accessory Export Packaging]
Price: $0.08
List Price: $0.00 |
|
Otterbox Defender Case for iPhone 3G, 3G S (Black)
Price: Too low to display
List Price: $49.95 |
|
iPhone 3G Stylus
Price: $0.01
List Price: $19.99 |
Apple's iPhone in the News
- Claim that crappy iPhone service is Apple's fault is bunkum (Updated)Ars Technica3 days ago
iPhone users all over the US generally agree that AT&T's 3G service is nowhere near as stellar as the company claims—we have seen the look on iPhone users' faces when an AT&T commercial brags about the "fastest 3G network." But a recent report concludes that the blame is on Apple's shoddy design, not inadequacies of AT&T's network. We're not convinced this data supports such a conclusion though ...
- 2010 tech predictions: Apple's iPad tablet, 300,000 iPhone apps, '4G' networksMinnPost2 days ago
2010 tech predictions: Apple's iPad tablet, 300,000 iPhone apps, '4G' networks By Steve Borsch | Tuesday, Dec. 15, 2009 There are two broad themes from IDC, the global tech analyst firm: a "recovery" that brings more spending, and the focus on the "transformation" occurring in technology.
- Apple's "Worldwide Loyalty Team" Hunts Down Leakers Within the CompanyAnandTech35 hours ago
Details are emerging about Apple's aggressive corporate tactics thanks to a Gizmodo interview...
PrintShare it! — Rate it: up down flag this hub









