Alok Prabhakar
Alok Prabhakar

Reputation: 33

http headers converted to lowercase in iOS 11

While testing my iPad application on iOS 11 beta version, I observed a unique behaviour that HTTP headers coming in response are automatically converted to lowercase. How to change this behaviour programmatically? We have checks in code on the actual header name which aren't working with iOS 11 beta since header name is converted to lowercase.

Upvotes: 3

Views: 2378

Answers (2)

Vivienne
Vivienne

Reputation: 31

Note - the practice of headers being converted to lowercase is in adherence with preparation for the HTTP 2.0 Spec. For HTTP 1.0, headers were supposed to be case-insensitive bot this wasn't always followed. See https://evertpot.com/http-2-finalized/

Chrome update 60 already changed so that response headers are now lowercase ( which caused us some problems ! )

It is expected that all the browsers will follow suit with upcoming updates so this is something you need to take care of

Upvotes: 3

Patrik Nyblad
Patrik Nyblad

Reputation: 126

When answering this I assume that the HTTP headers you are talking about are only referring to the key and not the value of the headers.

You could use the NSString instance method -uppercaseString on the headers in case you want to compare with uppercase strings. It is a smart move to make your code case insensitive in case the server for some reason is edited to send lowercase or mixed case headers in the future.

If iOS is making the value of each header lowercase then that is very bad. I would recommend you to submit a bug report to Apple no matter if the key or the value casing is modified. Maybe you can verify with Charles Web Proxy to see that the response are actually changed.

Good luck!

Upvotes: 0

Related Questions