Fix for NSURLResponse does not allow for multiple Set-Cookie headers in the same response #85 ... combine multiple header values as a comma separated list.

This commit is contained in:
Richard Frith-Macdonald 2020-04-16 23:04:37 +01:00
parent 6d714c8ee1
commit 05f442de8b

View file

@ -114,12 +114,29 @@ typedef struct {
{
GSMimeHeader *h;
/* Remove existing headers matching the ones we are setting.
*/
e = [(NSArray*)headers objectEnumerator];
while ((h = [e nextObject]) != nil)
{
NSString *n = [h namePreservingCase: YES];
[this->headers removeObjectForKey: n];
}
/* Set new headers, joining values where we have multiple headers
* with the same name.
*/
e = [(NSArray*)headers objectEnumerator];
while ((h = [e nextObject]) != nil)
{
NSString *n = [h namePreservingCase: YES];
NSString *o = [this->headers objectForKey: n];
NSString *v = [h fullValue];
if (nil != o)
{
n = [NSString stringWithFormat: @"%@, %@", o, n];
}
[self _setValue: v forHTTPHeaderField: n];
}
}