Add some diagnostics

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27781 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2009-02-04 14:28:41 +00:00
parent 06fbe225d2
commit ef8b37000e
2 changed files with 37 additions and 3 deletions

View file

@ -2,6 +2,7 @@
* Source/NSURLProtocol.m: Add some diagnostics and ensure that
delegates are removed from streams.
* Source/NSURLConnection.m: Add diagnostics for redirect.
2009-02-04 David Chisnall <csdavec@swansea.ac.uk>

View file

@ -23,6 +23,7 @@
*/
#import <Foundation/NSRunLoop.h>
#import <Foundation/NSDebug.h>
#import "GSURLPrivate.h"
@ -144,6 +145,7 @@ typedef struct
NSURLRequest *_request;
NSURLProtocol *_protocol;
id _delegate; // Not retained
BOOL _debug;
} Internal;
typedef struct {
@ -160,8 +162,13 @@ typedef struct {
if (o != nil)
{
#if GS_WITH_GC
o->_NSURLConnectionInternal
= NSAllocateCollectable(sizeof(Internal), NSScannedOption);
#else
o->_NSURLConnectionInternal = NSZoneCalloc(GSObjCZone(self),
1, sizeof(Internal));
#endif
}
return o;
}
@ -180,6 +187,12 @@ typedef struct {
return AUTORELEASE(o);
}
- (void) cancel
{
[this->_protocol stopLoading];
DESTROY(this->_protocol);
}
- (void) dealloc
{
if (this != 0)
@ -192,10 +205,12 @@ typedef struct {
[super dealloc];
}
- (void) cancel
- (void) finalize
{
[this->_protocol stopLoading];
DESTROY(this->_protocol);
if (this != 0)
{
[self cancel];
}
}
- (id) initWithRequest: (NSURLRequest *)request delegate: (id)delegate
@ -209,6 +224,7 @@ typedef struct {
cachedResponse: nil
client: (id<NSURLProtocolClient>)self];
[this->_protocol startLoading];
this->_debug = GSDebugSet(@"NSURLConnection");
}
return self;
}
@ -347,17 +363,30 @@ typedef struct {
wasRedirectedToRequest: (NSURLRequest *)request
redirectResponse: (NSURLResponse *)redirectResponse
{
if (this->_debug)
{
NSLog(@"%@ tell delegate %@ about redirect to %@ as a result of %@",
self, this->_delegate, request, redirectResponse);
}
request = [this->_delegate connection: self
willSendRequest: request
redirectResponse: redirectResponse];
if (this->_protocol == nil)
{
if (this->_debug)
{
NSLog(@"%@ delegate cancelled request", self);
}
/* Our protocol is nil, so we have been cancelled by the delegate.
*/
return;
}
if (request != nil)
{
if (this->_debug)
{
NSLog(@"%@ delegate allowed redirect to %@", self, request);
}
/* Follow the redirect ... stop the old load and start a new one.
*/
[this->_protocol stopLoading];
@ -369,6 +398,10 @@ typedef struct {
client: (id<NSURLProtocolClient>)self];
[this->_protocol startLoading];
}
else if (this->_debug)
{
NSLog(@"%@ delegate cancelled redirect", self);
}
}
- (void) URLProtocolDidFinishLoading: (NSURLProtocol *)protocol