mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 16:50:58 +00:00
Make URL clients a bit safer.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@21929 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
9fc30bae77
commit
05a94eb676
3 changed files with 25 additions and 2 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2005-10-31 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/GSHTTPURLHandle.m: retain self for the duration of I/O
|
||||||
|
handler methods where we may make callbacks to clients. In case
|
||||||
|
the client owns the handle, and decides to release it.
|
||||||
|
|
||||||
2005-10-30 Richard Frith-Macdonald <rfm@gnu.org>
|
2005-10-30 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSLog.m: Apply patch #5399 from Jeremy Bettis.
|
* Source/NSLog.m: Apply patch #5399 from Jeremy Bettis.
|
||||||
|
|
|
@ -368,6 +368,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
||||||
NSString *version;
|
NSString *version;
|
||||||
NSMapEnumerator enumerator;
|
NSMapEnumerator enumerator;
|
||||||
|
|
||||||
|
RETAIN(self);
|
||||||
if (debug) NSLog(@"%@ %s", NSStringFromSelector(_cmd), keepalive?"K":"");
|
if (debug) NSLog(@"%@ %s", NSStringFromSelector(_cmd), keepalive?"K":"");
|
||||||
|
|
||||||
s = [basic mutableCopy];
|
s = [basic mutableCopy];
|
||||||
|
@ -457,6 +458,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
||||||
[sock writeInBackgroundAndNotify: buf];
|
[sock writeInBackgroundAndNotify: buf];
|
||||||
RELEASE(buf);
|
RELEASE(buf);
|
||||||
RELEASE(s);
|
RELEASE(s);
|
||||||
|
RELEASE(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) bgdRead: (NSNotification*) not
|
- (void) bgdRead: (NSNotification*) not
|
||||||
|
@ -466,6 +468,8 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
||||||
NSData *d;
|
NSData *d;
|
||||||
NSRange r;
|
NSRange r;
|
||||||
|
|
||||||
|
RETAIN(self);
|
||||||
|
|
||||||
if (debug) NSLog(@"%@ %s", NSStringFromSelector(_cmd), keepalive?"K":"");
|
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);
|
||||||
|
@ -596,11 +600,13 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
||||||
loadComplete: NO];
|
loadComplete: NO];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sock != nil)
|
if (sock != nil
|
||||||
|
&& (connectionState == reading || connectionState == idle))
|
||||||
{
|
{
|
||||||
[sock readInBackgroundAndNotify];
|
[sock readInBackgroundAndNotify];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
RELEASE(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) bgdTunnelRead: (NSNotification*) not
|
- (void) bgdTunnelRead: (NSNotification*) not
|
||||||
|
@ -610,6 +616,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
||||||
NSData *d;
|
NSData *d;
|
||||||
GSMimeParser *p = [GSMimeParser new];
|
GSMimeParser *p = [GSMimeParser new];
|
||||||
|
|
||||||
|
RETAIN(self);
|
||||||
if (debug) NSLog(@"%@ %s", NSStringFromSelector(_cmd), keepalive?"K":"");
|
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);
|
||||||
|
@ -646,6 +653,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
||||||
[sock readInBackgroundAndNotify];
|
[sock readInBackgroundAndNotify];
|
||||||
}
|
}
|
||||||
RELEASE(p);
|
RELEASE(p);
|
||||||
|
RELEASE(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) loadInBackground
|
- (void) loadInBackground
|
||||||
|
@ -680,13 +688,13 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
||||||
- (void) bgdConnect: (NSNotification*)notification
|
- (void) bgdConnect: (NSNotification*)notification
|
||||||
{
|
{
|
||||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
NSDictionary *userInfo = [notification userInfo];
|
NSDictionary *userInfo = [notification userInfo];
|
||||||
NSMutableString *s;
|
NSMutableString *s;
|
||||||
NSString *e;
|
NSString *e;
|
||||||
NSString *method;
|
NSString *method;
|
||||||
NSString *path;
|
NSString *path;
|
||||||
|
|
||||||
|
RETAIN(self);
|
||||||
if (debug) NSLog(@"%@ %s", NSStringFromSelector(_cmd), keepalive?"K":"");
|
if (debug) NSLog(@"%@ %s", NSStringFromSelector(_cmd), keepalive?"K":"");
|
||||||
|
|
||||||
path = [[u path] stringByTrimmingSpaces];
|
path = [[u path] stringByTrimmingSpaces];
|
||||||
|
@ -709,6 +717,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
||||||
[self endLoadInBackground];
|
[self endLoadInBackground];
|
||||||
[self backgroundLoadDidFailWithReason:
|
[self backgroundLoadDidFailWithReason:
|
||||||
[NSString stringWithFormat: @"Failed to connect: %@", e]];
|
[NSString stringWithFormat: @"Failed to connect: %@", e]];
|
||||||
|
RELEASE(self);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -789,6 +798,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
||||||
{
|
{
|
||||||
[self endLoadInBackground];
|
[self endLoadInBackground];
|
||||||
[self backgroundLoadDidFailWithReason: @"Failed proxy tunneling"];
|
[self backgroundLoadDidFailWithReason: @"Failed proxy tunneling"];
|
||||||
|
RELEASE(self);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -802,6 +812,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
||||||
[self endLoadInBackground];
|
[self endLoadInBackground];
|
||||||
[self backgroundLoadDidFailWithReason:
|
[self backgroundLoadDidFailWithReason:
|
||||||
@"Failed to make ssl connect"];
|
@"Failed to make ssl connect"];
|
||||||
|
RELEASE(self);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -843,6 +854,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
||||||
|
|
||||||
[self bgdApply: s];
|
[self bgdApply: s];
|
||||||
RELEASE(s);
|
RELEASE(s);
|
||||||
|
RELEASE(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) bgdWrite: (NSNotification*)notification
|
- (void) bgdWrite: (NSNotification*)notification
|
||||||
|
@ -851,6 +863,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
||||||
NSDictionary *userInfo = [notification userInfo];
|
NSDictionary *userInfo = [notification userInfo];
|
||||||
NSString *e;
|
NSString *e;
|
||||||
|
|
||||||
|
RETAIN(self);
|
||||||
if (debug) NSLog(@"%@ %s", NSStringFromSelector(_cmd), keepalive?"K":"");
|
if (debug) NSLog(@"%@ %s", NSStringFromSelector(_cmd), keepalive?"K":"");
|
||||||
e = [userInfo objectForKey: GSFileHandleNotificationError];
|
e = [userInfo objectForKey: GSFileHandleNotificationError];
|
||||||
if (e != nil)
|
if (e != nil)
|
||||||
|
@ -880,6 +893,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
||||||
[self endLoadInBackground];
|
[self endLoadInBackground];
|
||||||
[self backgroundLoadDidFailWithReason:
|
[self backgroundLoadDidFailWithReason:
|
||||||
[NSString stringWithFormat: @"Failed to write request: %@", e]];
|
[NSString stringWithFormat: @"Failed to write request: %@", e]];
|
||||||
|
RELEASE(self);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -916,6 +930,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
||||||
}
|
}
|
||||||
connectionState = reading;
|
connectionState = reading;
|
||||||
}
|
}
|
||||||
|
RELEASE(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -317,10 +317,12 @@ static Class NSURLHandleClass = 0;
|
||||||
*/
|
*/
|
||||||
- (void) cancelLoadInBackground
|
- (void) cancelLoadInBackground
|
||||||
{
|
{
|
||||||
|
RETAIN(self);
|
||||||
[_clients makeObjectsPerformSelector:
|
[_clients makeObjectsPerformSelector:
|
||||||
@selector(URLHandleResourceDidCancelLoading:)
|
@selector(URLHandleResourceDidCancelLoading:)
|
||||||
withObject: self];
|
withObject: self];
|
||||||
[self endLoadInBackground];
|
[self endLoadInBackground];
|
||||||
|
RELEASE(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue