small tweak for lowering resource usage during very heavy use of outgoing

connections.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@33950 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2011-10-07 15:15:05 +00:00
parent f7280475ff
commit 5021629c2b
2 changed files with 35 additions and 2 deletions

View file

@ -1,3 +1,9 @@
2011-10-07 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSHTTPURLHandle.m:
Be aggressive about checking for close n the 'connection' header
and shutting down the network connection immediately.
2011-10-07 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSURLProtocol.m:

View file

@ -651,13 +651,40 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
[nc removeObserver: self name: nil object: sock];
ver = [[[document headerNamed: @"http"] value] floatValue];
val = [[document headerNamed: @"connection"] value];
if (ver < 1.1 || (val != nil && [val isEqual: @"close"] == YES))
if (ver < 1.1)
{
[nc removeObserver: self name: nil object: sock];
[sock closeFile];
DESTROY(sock);
}
else if (nil != (val = [[document headerNamed: @"connection"] value]))
{
val = [val lowercaseString];
if (YES == [val isEqualToString: @"close"])
{
[nc removeObserver: self name: nil object: sock];
[sock closeFile];
DESTROY(sock);
}
else if ([val length] > 5)
{
NSEnumerator *e;
e = [[val componentsSeparatedByString: @","]
objectEnumerator];
while (nil != (val = [e nextObject]))
{
val = [val stringByTrimmingSpaces];
if (YES == [val isEqualToString: @"close"])
{
[nc removeObserver: self name: nil object: sock];
[sock closeFile];
DESTROY(sock);
break;
}
}
}
}
/*
* Retrieve essential keys from document