You are too sensitive, NSHTTPURLResponse

The SDK for iOS development is really nifty. It has high level access to a lot of the OS and offers plenty of widgets and utilities. There is, however, one unexpected weakness I had to battle recently. That is NSHTTPURLResponse‘s header management.

There was some useful info in the response headers of a webservice’s response, Twitter’s rate limiting info. It seemed like a simple thing to do. Just take the header name from the service documentation and extract the value from the response’s header dictionary. To my surprise, the name of the header in the spec and the actual response didn’t match for one uppercase letter. It turns out that HTTP doesn’t care about case, but the response object doesn’t care.

For the solution I chose to just loop through the headers and find the right ones myself. Somehow though, I feel if the response object implies awareness of the protocol it should allow access to the headers in a case insensitive way.

:>

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.