mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +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
8c87fa2a6d
commit
c499bc0878
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>
|
||||
|
||||
* Source/NSLog.m: Apply patch #5399 from Jeremy Bettis.
|
||||
|
|
|
@ -368,6 +368,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
|||
NSString *version;
|
||||
NSMapEnumerator enumerator;
|
||||
|
||||
RETAIN(self);
|
||||
if (debug) NSLog(@"%@ %s", NSStringFromSelector(_cmd), keepalive?"K":"");
|
||||
|
||||
s = [basic mutableCopy];
|
||||
|
@ -457,6 +458,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
|||
[sock writeInBackgroundAndNotify: buf];
|
||||
RELEASE(buf);
|
||||
RELEASE(s);
|
||||
RELEASE(self);
|
||||
}
|
||||
|
||||
- (void) bgdRead: (NSNotification*) not
|
||||
|
@ -466,6 +468,8 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
|||
NSData *d;
|
||||
NSRange r;
|
||||
|
||||
RETAIN(self);
|
||||
|
||||
if (debug) NSLog(@"%@ %s", NSStringFromSelector(_cmd), keepalive?"K":"");
|
||||
d = [dict objectForKey: NSFileHandleNotificationDataItem];
|
||||
if (debug == YES) debugRead(self, d);
|
||||
|
@ -596,11 +600,13 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
|||
loadComplete: NO];
|
||||
}
|
||||
}
|
||||
if (sock != nil)
|
||||
if (sock != nil
|
||||
&& (connectionState == reading || connectionState == idle))
|
||||
{
|
||||
[sock readInBackgroundAndNotify];
|
||||
}
|
||||
}
|
||||
RELEASE(self);
|
||||
}
|
||||
|
||||
- (void) bgdTunnelRead: (NSNotification*) not
|
||||
|
@ -610,6 +616,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
|||
NSData *d;
|
||||
GSMimeParser *p = [GSMimeParser new];
|
||||
|
||||
RETAIN(self);
|
||||
if (debug) NSLog(@"%@ %s", NSStringFromSelector(_cmd), keepalive?"K":"");
|
||||
d = [dict objectForKey: NSFileHandleNotificationDataItem];
|
||||
if (debug == YES) debugRead(self, d);
|
||||
|
@ -646,6 +653,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
|||
[sock readInBackgroundAndNotify];
|
||||
}
|
||||
RELEASE(p);
|
||||
RELEASE(self);
|
||||
}
|
||||
|
||||
- (void) loadInBackground
|
||||
|
@ -680,13 +688,13 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
|||
- (void) bgdConnect: (NSNotification*)notification
|
||||
{
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
|
||||
NSDictionary *userInfo = [notification userInfo];
|
||||
NSMutableString *s;
|
||||
NSString *e;
|
||||
NSString *method;
|
||||
NSString *path;
|
||||
|
||||
RETAIN(self);
|
||||
if (debug) NSLog(@"%@ %s", NSStringFromSelector(_cmd), keepalive?"K":"");
|
||||
|
||||
path = [[u path] stringByTrimmingSpaces];
|
||||
|
@ -709,6 +717,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
|||
[self endLoadInBackground];
|
||||
[self backgroundLoadDidFailWithReason:
|
||||
[NSString stringWithFormat: @"Failed to connect: %@", e]];
|
||||
RELEASE(self);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -789,6 +798,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
|||
{
|
||||
[self endLoadInBackground];
|
||||
[self backgroundLoadDidFailWithReason: @"Failed proxy tunneling"];
|
||||
RELEASE(self);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -802,6 +812,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
|||
[self endLoadInBackground];
|
||||
[self backgroundLoadDidFailWithReason:
|
||||
@"Failed to make ssl connect"];
|
||||
RELEASE(self);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -843,6 +854,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
|||
|
||||
[self bgdApply: s];
|
||||
RELEASE(s);
|
||||
RELEASE(self);
|
||||
}
|
||||
|
||||
- (void) bgdWrite: (NSNotification*)notification
|
||||
|
@ -851,6 +863,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
|||
NSDictionary *userInfo = [notification userInfo];
|
||||
NSString *e;
|
||||
|
||||
RETAIN(self);
|
||||
if (debug) NSLog(@"%@ %s", NSStringFromSelector(_cmd), keepalive?"K":"");
|
||||
e = [userInfo objectForKey: GSFileHandleNotificationError];
|
||||
if (e != nil)
|
||||
|
@ -880,6 +893,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
|||
[self endLoadInBackground];
|
||||
[self backgroundLoadDidFailWithReason:
|
||||
[NSString stringWithFormat: @"Failed to write request: %@", e]];
|
||||
RELEASE(self);
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
@ -916,6 +930,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
|||
}
|
||||
connectionState = reading;
|
||||
}
|
||||
RELEASE(self);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -317,10 +317,12 @@ static Class NSURLHandleClass = 0;
|
|||
*/
|
||||
- (void) cancelLoadInBackground
|
||||
{
|
||||
RETAIN(self);
|
||||
[_clients makeObjectsPerformSelector:
|
||||
@selector(URLHandleResourceDidCancelLoading:)
|
||||
withObject: self];
|
||||
[self endLoadInBackground];
|
||||
RELEASE(self);
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
|
|
Loading…
Reference in a new issue