Skip to content

Commit

Permalink
Fix NSURLSession header fields not always being matched case insensit…
Browse files Browse the repository at this point in the history
…ive.
  • Loading branch information
triplef committed Jan 13, 2023
1 parent c2b2785 commit 8ca684c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
2023-01-13 Frederik Seiffert <[email protected]>

* Source/Additions/GSInsensitiveDictionary.m:
* Source/NSURLRequest.m:
* Source/NSURLResponse.m:
Fix NSURLSession header fields not always being matched case
insensitive.

2023-01-13 Frederik Seiffert <[email protected]>

* Source/GSEasyHandle.m:
Expand Down
7 changes: 7 additions & 0 deletions Source/Additions/GSInsensitiveDictionary.m
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,13 @@ - (id) copyWithZone: (NSZone*)zone
return [copy initWithDictionary: self copyItems: NO];
}

- (id) mutableCopyWithZone: (NSZone*)z
{
NSMutableDictionary *copy = [_GSMutableInsensitiveDictionary allocWithZone: z];

return [copy initWithDictionary: self copyItems: NO];
}

- (id) init
{
return [self initWithCapacity: 0];
Expand Down
1 change: 0 additions & 1 deletion Source/Additions/GSMime.m
Original file line number Diff line number Diff line change
Expand Up @@ -3345,7 +3345,6 @@ - (BOOL) _scanHeaderParameters: (NSScanner*)scanner into: (GSMimeHeader*)info

@end



@interface _GSMutableInsensitiveDictionary : NSMutableDictionary
@end
Expand Down
2 changes: 1 addition & 1 deletion Source/NSURLRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ - (id) copyWithZone: (NSZone*)z
inst->shouldHandleCookies = this->shouldHandleCookies;
inst->debug = this->debug;
inst->ioDelegate = this->ioDelegate;
inst->headers = [this->headers mutableCopy];
inst->headers = [this->headers mutableCopy];
}
}
return o;
Expand Down
9 changes: 8 additions & 1 deletion Source/NSURLResponse.m
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,15 @@ - (id) initWithURL: (NSURL*)URL
textEncodingName: nil];
if (nil != self)
{
NSString *k;
NSEnumerator *e = [headerFields keyEnumerator];
while (nil != (k = [e nextObject]))
{
NSString *v = [headerFields objectForKey: k];
[self _setValue: v forHTTPHeaderField: k];
}

this->statusCode = statusCode;
this->headers = [headerFields copy];
[self _checkHeaders];
}
return self;
Expand Down

0 comments on commit 8ca684c

Please sign in to comment.