From cb42f0bb8f87b228b848391b3d63bf4163c98c25 Mon Sep 17 00:00:00 2001 From: rfm Date: Mon, 14 May 2007 09:46:53 +0000 Subject: [PATCH] Minor tweaks and comments added git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@25150 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 9 ++++++++- Source/NSURLConnection.m | 31 +++++++++++++++++-------------- Source/NSURLProtocol.m | 4 ++++ Source/NSURLRequest.m | 8 ++++++-- 4 files changed, 35 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index adb1185ad..388653730 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-05-14 Richard Frith-Macdonald + + * Source/NSURLProtocol.m: + * Source/NSURLRequest.m: + * Source/NSURLConnection.m: + Added tweaks for redirection andvarious comments. + 2007-05-14 Richard Frith-Macdonald * Source/Additions/Unicode.m: @@ -63,7 +70,7 @@ 2007-04-27 Richard Frith-Macdonald - * Source/NSBundle.m: Reformat for conding standards. Alter library + * Source/NSBundle.m: Reformat for coding standards. Alter library resource lookup to find correct version when multiple versions of the base library are installed and the old unversioned api is used. * Source/NSURLHandle.m: Scheduling tweak. diff --git a/Source/NSURLConnection.m b/Source/NSURLConnection.m index d6f1004e3..796dbb5e9 100644 --- a/Source/NSURLConnection.m +++ b/Source/NSURLConnection.m @@ -340,8 +340,7 @@ typedef struct { if (policy == NSURLCacheStorageAllowed || policy == NSURLCacheStorageAllowedInMemoryOnly) { - - // FIXME ... cache response here + // FIXME ... cache response here? } } @@ -352,19 +351,23 @@ typedef struct { request = [_delegate connection: _parent willSendRequest: request redirectResponse: redirectResponse]; - // If we have been cancelled, our protocol will be nil - if (_protocol != nil) + if (this->_protocol == nil) { - if (request == nil) - { - [_delegate connectionDidFinishLoading: _parent]; - } - else - { - [_protocol stopLoading]; - DESTROY(_protocol); - // FIXME start new request loading - } + /* Our protocol is nil, so we have been cancelled by the delegate. + */ + return; + } + if (request != nil) + { + /* Follow the redirect ... stop the old load and start a new one. + */ + [_protocol stopLoading]; + DESTROY(this->_protocol); + ASSIGNCOPY(this->_request, request); + this->_protocol = [[NSURLProtocol alloc] initWithRequest: this->_request + cachedResponse: nil + client: this]; + [this->_protocol startLoading]; } } diff --git a/Source/NSURLProtocol.m b/Source/NSURLProtocol.m index 1d386e46a..1ab4f080a 100644 --- a/Source/NSURLProtocol.m +++ b/Source/NSURLProtocol.m @@ -754,6 +754,10 @@ static NSURLProtocol *placeholder = nil; - (void) stream: (NSStream*) stream handleEvent: (NSStreamEvent) event { + /* Make sure no action triggered by anything else destroys us prematurely. + */ + AUTORELEASE(RETAIN(self)); + #if 0 NSLog(@"stream: %@ handleEvent: %x for: %@", stream, event, self); #endif diff --git a/Source/NSURLRequest.m b/Source/NSURLRequest.m index 2869c5814..1e72cd3bf 100644 --- a/Source/NSURLRequest.m +++ b/Source/NSURLRequest.m @@ -354,13 +354,17 @@ typedef struct { static unsigned int _non_retained_id_hash(void *table, NSString* o) { - return [[o uppercaseString] hash]; + return [[o lowercaseString] hash]; } static BOOL _non_retained_id_is_equal(void *table, NSString *o, NSString *p) { - return ([o caseInsensitiveCompare: p] == NSOrderedSame) ? YES : NO; + if (o == nil || [o caseInsensitiveCompare: p] != NSOrderedSame) + { + return NO; + } + return YES; } typedef unsigned int (*NSMT_hash_func_t)(NSMapTable *, const void *);