mirror of
https://github.com/apple/swift-nio
synced 2026-11-24 04:37:54 +00:00
Motivation: In some cases you only expect (or care about) a single value for a header. However, getting this value without allocating an array or traversing the whole array requres using first(where:) provided by Sequence. This is not very ergonomic as it requires users to do the case-insensitive comparison and then exctact the value from the HTTPHeaders. Additionally, users cannot use NIO's case insensitive ASCII comparison. Modifications: - Provide a first(name:) method on HTTPHeaders which returns the value from the first header whose name is a case insentive match of the subscript parameter. Result: It's easier to get the first value from HTTPHeaders matching a given name.