From 8fb0f1c29efa544bba8d162d5395d321c9c01964 Mon Sep 17 00:00:00 2001 From: Rod H Date: Thu, 30 Nov 2017 10:43:56 -0500 Subject: [PATCH] Added components separated by "," for Firefox only if ";" results to 1 component and "," results to more components. --- PocketSocket/PSWebSocketInternal.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/PocketSocket/PSWebSocketInternal.h b/PocketSocket/PSWebSocketInternal.h index 60ef669..bf4db75 100644 --- a/PocketSocket/PSWebSocketInternal.h +++ b/PocketSocket/PSWebSocketInternal.h @@ -92,7 +92,14 @@ static inline BOOL PSWebSocketCloseCodeIsValid(NSInteger closeCode) { static inline NSOrderedSet* PSHTTPHeaderFieldValues(NSString *header) { NSMutableOrderedSet *components = [NSMutableOrderedSet orderedSet]; - [[header componentsSeparatedByString:@";"] enumerateObjectsUsingBlock:^(NSString * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + + //Firefox sends headers separated by ',' + NSArray *componentValues = [header componentsSeparatedByString:@";"]; + if (componentValues.count == 1 && [header componentsSeparatedByString:@","].count > 1) { + componentValues = [header componentsSeparatedByString:@","]; + } + + [componentValues enumerateObjectsUsingBlock:^(NSString * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { NSString *str = obj; while ([str hasPrefix:@" "] && str.length > 1) { str = [str substringWithRange:NSMakeRange(1, str.length - 1)];