mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Allow debug to be turned on for an individual request
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@38958 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c03f00d938
commit
6e88b865d5
4 changed files with 40 additions and 44 deletions
|
@ -57,6 +57,7 @@
|
|||
*/
|
||||
|
||||
@interface NSURLRequest (Private)
|
||||
- (BOOL) _debug;
|
||||
- (id) _propertyForKey: (NSString*)key;
|
||||
- (void) _setProperty: (id)value forKey: (NSString*)key;
|
||||
@end
|
||||
|
|
|
@ -110,7 +110,6 @@
|
|||
_done = YES;
|
||||
}
|
||||
|
||||
|
||||
- (void) connection: (NSURLConnection *)connection
|
||||
didReceiveData: (NSData *)data
|
||||
{
|
||||
|
|
|
@ -352,7 +352,6 @@ static NSLock *pairLock = nil;
|
|||
NSURLCredential *_credential;
|
||||
NSHTTPURLResponse *_response;
|
||||
}
|
||||
- (void) setDebug: (BOOL)flag;
|
||||
@end
|
||||
|
||||
@interface _NSHTTPSURLProtocol : _NSHTTPURLProtocol
|
||||
|
@ -472,28 +471,6 @@ static NSURLProtocol *placeholder = nil;
|
|||
return NO;
|
||||
}
|
||||
|
||||
+ (Class) _classToHandleRequest:(NSURLRequest *)request
|
||||
{
|
||||
Class protoClass = nil;
|
||||
int count;
|
||||
[regLock lock];
|
||||
|
||||
count = [registered count];
|
||||
while (count-- > 0)
|
||||
{
|
||||
Class proto = [registered objectAtIndex: count];
|
||||
|
||||
if ([proto canInitWithRequest: request] == YES)
|
||||
{
|
||||
protoClass = proto;
|
||||
break;
|
||||
}
|
||||
}
|
||||
[regLock unlock];
|
||||
return protoClass;
|
||||
}
|
||||
|
||||
|
||||
+ (void) setProperty: (id)value
|
||||
forKey: (NSString *)key
|
||||
inRequest: (NSMutableURLRequest *)request
|
||||
|
@ -618,17 +595,33 @@ static NSURLProtocol *placeholder = nil;
|
|||
return this->request;
|
||||
}
|
||||
|
||||
/* This method is here so that it's safe to set debug on any NSURLProtocol
|
||||
* even if the concrete subclass doesn't actually support debug logging.
|
||||
*/
|
||||
- (void) setDebug: (BOOL)flag
|
||||
@end
|
||||
|
||||
@implementation NSURLProtocol (Private)
|
||||
|
||||
+ (Class) _classToHandleRequest:(NSURLRequest *)request
|
||||
{
|
||||
return;
|
||||
Class protoClass = nil;
|
||||
int count;
|
||||
[regLock lock];
|
||||
|
||||
count = [registered count];
|
||||
while (count-- > 0)
|
||||
{
|
||||
Class proto = [registered objectAtIndex: count];
|
||||
|
||||
if ([proto canInitWithRequest: request] == YES)
|
||||
{
|
||||
protoClass = proto;
|
||||
break;
|
||||
}
|
||||
}
|
||||
[regLock unlock];
|
||||
return protoClass;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation NSURLProtocol (Subclassing)
|
||||
|
||||
+ (BOOL) canInitWithRequest: (NSURLRequest *)request
|
||||
|
@ -705,24 +698,13 @@ static NSURLProtocol *placeholder = nil;
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if (nil != (self = [super init]))
|
||||
{
|
||||
_debug = GSDebugSet(@"NSURLProtocol");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) setDebug: (BOOL)flag
|
||||
{
|
||||
_debug = flag;
|
||||
}
|
||||
|
||||
- (void) startLoading
|
||||
{
|
||||
static NSDictionary *methods = nil;
|
||||
|
||||
_debug = GSDebugSet(@"NSURLProtocol");
|
||||
if (YES == [this->request _debug]) _debug = YES;
|
||||
|
||||
if (methods == nil)
|
||||
{
|
||||
methods = [[NSDictionary alloc] initWithObjectsAndKeys:
|
||||
|
|
|
@ -38,6 +38,7 @@ typedef struct {
|
|||
NSString *method;
|
||||
NSMutableDictionary *headers;
|
||||
BOOL shouldHandleCookies;
|
||||
BOOL debug;
|
||||
NSURL *URL;
|
||||
NSURL *mainDocumentURL;
|
||||
NSURLRequestCachePolicy cachePolicy;
|
||||
|
@ -114,6 +115,7 @@ typedef struct {
|
|||
ASSIGN(inst->bodyStream, this->bodyStream);
|
||||
ASSIGN(inst->method, this->method);
|
||||
inst->shouldHandleCookies = this->shouldHandleCookies;
|
||||
inst->debug = this->debug;
|
||||
inst->headers = [this->headers mutableCopy];
|
||||
}
|
||||
}
|
||||
|
@ -268,11 +270,17 @@ typedef struct {
|
|||
ASSIGN(inst->bodyStream, this->bodyStream);
|
||||
ASSIGN(inst->method, this->method);
|
||||
inst->shouldHandleCookies = this->shouldHandleCookies;
|
||||
inst->debug = this->debug;
|
||||
inst->headers = [this->headers mutableCopy];
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
- (void) setDebug: (BOOL)flag
|
||||
{
|
||||
this->debug = flag;
|
||||
}
|
||||
|
||||
- (NSTimeInterval) timeoutInterval
|
||||
{
|
||||
return this->timeoutInterval;
|
||||
|
@ -427,6 +435,12 @@ typedef struct {
|
|||
@end
|
||||
|
||||
@implementation NSURLRequest (Private)
|
||||
|
||||
- (BOOL) _debug
|
||||
{
|
||||
return this->debug;
|
||||
}
|
||||
|
||||
- (id) _propertyForKey: (NSString*)key
|
||||
{
|
||||
return [this->properties objectForKey: key];
|
||||
|
|
Loading…
Reference in a new issue