mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-01 09:02:01 +00:00
Fix for problems when remote host drops persistent http/https connections.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@21166 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
98e77b9474
commit
a03f16128d
2 changed files with 44 additions and 8 deletions
|
@ -3,6 +3,10 @@
|
||||||
* Documentation/coding-standards.texi: Added what appear to be the
|
* Documentation/coding-standards.texi: Added what appear to be the
|
||||||
generally accepted parts of Sheldon's suggested coding standards
|
generally accepted parts of Sheldon's suggested coding standards
|
||||||
additions.
|
additions.
|
||||||
|
* Source/GSHTTPURLHandle.m: Modified to keep watching idle connections
|
||||||
|
and handle things properly when the remote end drops the connection.
|
||||||
|
Should fix occasional trouble when connectioin keepalive is used but
|
||||||
|
the remote host drops the connection between requests.
|
||||||
|
|
||||||
2005-04-26 Richard Frith-Macdonald <rfm@gnu.org>
|
2005-04-26 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
|
|
@ -315,7 +315,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
||||||
NSMutableData *buf;
|
NSMutableData *buf;
|
||||||
NSString *version;
|
NSString *version;
|
||||||
|
|
||||||
if (debug == YES) NSLog(@"%@", NSStringFromSelector(_cmd));
|
if (debug) NSLog(@"%@ %s", NSStringFromSelector(_cmd), keepalive?"K":"");
|
||||||
|
|
||||||
s = [basic mutableCopy];
|
s = [basic mutableCopy];
|
||||||
if ([[u query] length] > 0)
|
if ([[u query] length] > 0)
|
||||||
|
@ -411,10 +411,29 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
||||||
NSData *d;
|
NSData *d;
|
||||||
NSRange r;
|
NSRange r;
|
||||||
|
|
||||||
|
if (debug) NSLog(@"%@ %s", NSStringFromSelector(_cmd), keepalive?"K":"");
|
||||||
d = [dict objectForKey: NSFileHandleNotificationDataItem];
|
d = [dict objectForKey: NSFileHandleNotificationDataItem];
|
||||||
if (debug == YES) debugRead(self, d);
|
if (debug == YES) debugRead(self, d);
|
||||||
|
|
||||||
if ([parser parse: d] == NO)
|
if (connectionState == idle)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* We received an event on a handle which is not in use ...
|
||||||
|
* it should just be the connection being closed by the other
|
||||||
|
* end because of a timeout etc.
|
||||||
|
*/
|
||||||
|
if (debug == YES && [d length] != 0)
|
||||||
|
{
|
||||||
|
NSLog(@"%@ %s Unexpected data from remote!",
|
||||||
|
NSStringFromSelector(_cmd), keepalive?"K":"");
|
||||||
|
}
|
||||||
|
[nc removeObserver: self
|
||||||
|
name: NSFileHandleReadCompletionNotification
|
||||||
|
object: sock];
|
||||||
|
[sock closeFile];
|
||||||
|
DESTROY(sock);
|
||||||
|
}
|
||||||
|
else if ([parser parse: d] == NO)
|
||||||
{
|
{
|
||||||
if (debug == YES)
|
if (debug == YES)
|
||||||
{
|
{
|
||||||
|
@ -465,14 +484,14 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
||||||
float ver;
|
float ver;
|
||||||
|
|
||||||
connectionState = idle;
|
connectionState = idle;
|
||||||
[nc removeObserver: self
|
|
||||||
name: NSFileHandleReadCompletionNotification
|
|
||||||
object: sock];
|
|
||||||
|
|
||||||
ver = [[[document headerNamed: @"http"] value] floatValue];
|
ver = [[[document headerNamed: @"http"] value] floatValue];
|
||||||
val = [[document headerNamed: @"connection"] value];
|
val = [[document headerNamed: @"connection"] value];
|
||||||
if (ver < 1.1 || (val != nil && [val isEqual: @"close"] == YES))
|
if (ver < 1.1 || (val != nil && [val isEqual: @"close"] == YES))
|
||||||
{
|
{
|
||||||
|
[nc removeObserver: self
|
||||||
|
name: NSFileHandleReadCompletionNotification
|
||||||
|
object: sock];
|
||||||
[sock closeFile];
|
[sock closeFile];
|
||||||
DESTROY(sock);
|
DESTROY(sock);
|
||||||
}
|
}
|
||||||
|
@ -521,6 +540,9 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
||||||
[self didLoadBytes: [d subdataWithRange: r]
|
[self didLoadBytes: [d subdataWithRange: r]
|
||||||
loadComplete: NO];
|
loadComplete: NO];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (sock != nil)
|
||||||
|
{
|
||||||
[sock readInBackgroundAndNotify];
|
[sock readInBackgroundAndNotify];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -533,6 +555,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
||||||
NSData *d;
|
NSData *d;
|
||||||
GSMimeParser *p = [GSMimeParser new];
|
GSMimeParser *p = [GSMimeParser new];
|
||||||
|
|
||||||
|
if (debug) NSLog(@"%@ %s", NSStringFromSelector(_cmd), keepalive?"K":"");
|
||||||
d = [dict objectForKey: NSFileHandleNotificationDataItem];
|
d = [dict objectForKey: NSFileHandleNotificationDataItem];
|
||||||
if (debug == YES) debugRead(self, d);
|
if (debug == YES) debugRead(self, d);
|
||||||
|
|
||||||
|
@ -609,7 +632,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
||||||
NSString *method;
|
NSString *method;
|
||||||
NSString *path;
|
NSString *path;
|
||||||
|
|
||||||
if (debug == YES) NSLog(@"%@", NSStringFromSelector(_cmd));
|
if (debug) NSLog(@"%@ %s", NSStringFromSelector(_cmd), keepalive?"K":"");
|
||||||
|
|
||||||
path = [[u path] stringByTrimmingSpaces];
|
path = [[u path] stringByTrimmingSpaces];
|
||||||
if ([path length] == 0)
|
if ([path length] == 0)
|
||||||
|
@ -772,7 +795,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
||||||
NSDictionary *userInfo = [notification userInfo];
|
NSDictionary *userInfo = [notification userInfo];
|
||||||
NSString *e;
|
NSString *e;
|
||||||
|
|
||||||
if (debug == YES) NSLog(@"%@", NSStringFromSelector(_cmd));
|
if (debug) NSLog(@"%@ %s", NSStringFromSelector(_cmd), keepalive?"K":"");
|
||||||
e = [userInfo objectForKey: GSFileHandleNotificationError];
|
e = [userInfo objectForKey: GSFileHandleNotificationError];
|
||||||
if (e != nil)
|
if (e != nil)
|
||||||
{
|
{
|
||||||
|
@ -830,7 +853,10 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
||||||
name: NSFileHandleReadCompletionNotification
|
name: NSFileHandleReadCompletionNotification
|
||||||
object: sock];
|
object: sock];
|
||||||
}
|
}
|
||||||
[sock readInBackgroundAndNotify];
|
if ([sock readInProgress] == NO)
|
||||||
|
{
|
||||||
|
[sock readInBackgroundAndNotify];
|
||||||
|
}
|
||||||
connectionState = reading;
|
connectionState = reading;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1068,6 +1094,12 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
||||||
NSString *path;
|
NSString *path;
|
||||||
NSString *basic;
|
NSString *basic;
|
||||||
|
|
||||||
|
// Stop waiting for connection to be closed down.
|
||||||
|
nc = [NSNotificationCenter defaultCenter];
|
||||||
|
[nc removeObserver: self
|
||||||
|
name: NSFileHandleReadCompletionNotification
|
||||||
|
object: sock];
|
||||||
|
|
||||||
keepalive = YES; // Reusing a connection.
|
keepalive = YES; // Reusing a connection.
|
||||||
method = [request objectForKey: GSHTTPPropertyMethodKey];
|
method = [request objectForKey: GSHTTPPropertyMethodKey];
|
||||||
if (method == nil)
|
if (method == nil)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue