#import "TQHTTPHeaderCompat.h"

@implementation TQHTTPHeaderCompat

+ (nullable NSString *)valueForHeaderField:(NSString *)field
                              inResponse:(NSURLResponse *)response {
    if (![response isKindOfClass:[NSHTTPURLResponse class]] || field.length == 0) {
        return nil;
    }
    NSHTTPURLResponse *http = (NSHTTPURLResponse *)response;
    NSString *lowerField = field.lowercaseString;
    for (NSString *key in http.allHeaderFields) {
        if ([key.lowercaseString isEqualToString:lowerField]) {
            return http.allHeaderFields[key];
        }
    }
    return nil;
}

@end
