diff --git a/flex-api-ios-sdk/FlexTokens Feature/HttpResponse.swift b/flex-api-ios-sdk/FlexTokens Feature/HttpResponse.swift index dc944c1..1620a78 100644 --- a/flex-api-ios-sdk/FlexTokens Feature/HttpResponse.swift +++ b/flex-api-ios-sdk/FlexTokens Feature/HttpResponse.swift @@ -11,7 +11,6 @@ struct HttpResponse: Equatable { static func == (lhs: HttpResponse, rhs: HttpResponse) -> Bool { return lhs.status == rhs.status && lhs.body == rhs.body } - let status: Int let body: String? let headers: [AnyHashable: Any]? @@ -21,16 +20,18 @@ struct HttpResponse: Equatable { self.body = body self.headers = headers } - func isValidResponse() -> Bool { (200...299).contains(self.status) } - func getValue(for key: String) -> String? { - if let field = self.headers?[key.lowercased()] as? String { - return field - } - - return nil + // attempt to get header value using exact key + if let field = self.headers?[key] as? String { + return field + } + + // Then try case-insensitive match if needed + return self.headers?.first(where: { + ($0.key as? String)?.lowercased() == key.lowercased() + })?.value as? String } }