Skip to content

Commit 8ca684c

Browse files
committed
Fix NSURLSession header fields not always being matched case insensitive.
1 parent c2b2785 commit 8ca684c

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2023-01-13 Frederik Seiffert <[email protected]>
2+
3+
* Source/Additions/GSInsensitiveDictionary.m:
4+
* Source/NSURLRequest.m:
5+
* Source/NSURLResponse.m:
6+
Fix NSURLSession header fields not always being matched case
7+
insensitive.
8+
19
2023-01-13 Frederik Seiffert <[email protected]>
210

311
* Source/GSEasyHandle.m:

Source/Additions/GSInsensitiveDictionary.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,13 @@ - (id) copyWithZone: (NSZone*)zone
378378
return [copy initWithDictionary: self copyItems: NO];
379379
}
380380

381+
- (id) mutableCopyWithZone: (NSZone*)z
382+
{
383+
NSMutableDictionary *copy = [_GSMutableInsensitiveDictionary allocWithZone: z];
384+
385+
return [copy initWithDictionary: self copyItems: NO];
386+
}
387+
381388
- (id) init
382389
{
383390
return [self initWithCapacity: 0];

Source/Additions/GSMime.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3345,7 +3345,6 @@ - (BOOL) _scanHeaderParameters: (NSScanner*)scanner into: (GSMimeHeader*)info
33453345

33463346
@end
33473347

3348-
33493348

33503349
@interface _GSMutableInsensitiveDictionary : NSMutableDictionary
33513350
@end

Source/NSURLRequest.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ - (id) copyWithZone: (NSZone*)z
118118
inst->shouldHandleCookies = this->shouldHandleCookies;
119119
inst->debug = this->debug;
120120
inst->ioDelegate = this->ioDelegate;
121-
inst->headers = [this->headers mutableCopy];
121+
inst->headers = [this->headers mutableCopy];
122122
}
123123
}
124124
return o;

Source/NSURLResponse.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,15 @@ - (id) initWithURL: (NSURL*)URL
284284
textEncodingName: nil];
285285
if (nil != self)
286286
{
287+
NSString *k;
288+
NSEnumerator *e = [headerFields keyEnumerator];
289+
while (nil != (k = [e nextObject]))
290+
{
291+
NSString *v = [headerFields objectForKey: k];
292+
[self _setValue: v forHTTPHeaderField: k];
293+
}
294+
287295
this->statusCode = statusCode;
288-
this->headers = [headerFields copy];
289296
[self _checkHeaders];
290297
}
291298
return self;

0 commit comments

Comments
 (0)