You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's a (very small) performance cost for doing this. Probably negligible, but it'd still be nicer to avoid it.
It doesn't preserve the case of assigned headers.
Headers are case-insensitive (which is why we do this), so not preserving the case has no functionality impacts, but it may be visible if header names are ever exposed to the user.
Note that we're already using a custom type to represent the headers, but we expose a var dictionary: [String: String] { get } property which is why we normalize instead of using a data structure that does case-insensitive comparisons. Solving this problem means doing one of the following:
Calculate the dictionary value when accessing the property. This could be memoized so it's only recalculated if anything changes, but it's still not great.
Get rid of the property entirely.
Publicly expose CaseInsensitiveASCIIString and change the property to be [CaseInsensitiveASCIIString: String], though if we did this we'd want to extend CaseInsensitiveASCIIString to do unicode comparisons. It's also not obj-c–compatible.
Define our own NSDictionary subclass that does case-insensitive comparisons and use obj-c bridging in order to use that as our data structure.
The text was updated successfully, but these errors were encountered:
Our current mechanism for handling request headers is to normalize header names when inserting or looking them up. This means that you can say
But this has two downsides:
Headers are case-insensitive (which is why we do this), so not preserving the case has no functionality impacts, but it may be visible if header names are ever exposed to the user.
Note that we're already using a custom type to represent the headers, but we expose a
var dictionary: [String: String] { get }
property which is why we normalize instead of using a data structure that does case-insensitive comparisons. Solving this problem means doing one of the following:CaseInsensitiveASCIIString
and change the property to be[CaseInsensitiveASCIIString: String]
, though if we did this we'd want to extendCaseInsensitiveASCIIString
to do unicode comparisons. It's also not obj-c–compatible.NSDictionary
subclass that does case-insensitive comparisons and use obj-c bridging in order to use that as our data structure.The text was updated successfully, but these errors were encountered: