Files
duooomi-ios-sdk/Sources/DuooomiBleSDK/Utils/HTTPURLResponse+Header.swift

20 lines
804 B
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import Foundation
extension HTTPURLResponse {
/// HTTP
///
/// HTTP/2RFC 7540 §8.1.2 `content-length`
/// `allHeaderFields` `["Content-Length"]`
/// HTTP/2 `value(forHTTPHeaderField:)`
/// iOS 13+ SDK iOS 12
func headerValue(caseInsensitive name: String) -> String? {
for (key, value) in allHeaderFields {
if let keyStr = key as? String,
keyStr.caseInsensitiveCompare(name) == .orderedSame {
return value as? String
}
}
return nil
}
}