Add more debug

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27779 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2009-02-04 12:59:13 +00:00
parent 676a044f5d
commit 091dd549e4

View file

@ -27,6 +27,7 @@
#import <Foundation/NSNotification.h> #import <Foundation/NSNotification.h>
#import <Foundation/NSRunLoop.h> #import <Foundation/NSRunLoop.h>
#import <Foundation/NSValue.h> #import <Foundation/NSValue.h>
#import <Foundation/NSDebug.h>
#import "GNUstepBase/GSMime.h" #import "GNUstepBase/GSMime.h"
@ -241,6 +242,7 @@ static NSLock *pairLock = nil;
NSURLCredential *_credential; NSURLCredential *_credential;
NSHTTPURLResponse *_response; NSHTTPURLResponse *_response;
} }
- (void) setDebug: (BOOL)flag;
@end @end
@interface _NSHTTPSURLProtocol : _NSHTTPURLProtocol @interface _NSHTTPSURLProtocol : _NSHTTPURLProtocol
@ -543,6 +545,11 @@ static NSURLProtocol *placeholder = nil;
forMode: NSDefaultRunLoopMode]; forMode: NSDefaultRunLoopMode];
} }
- (void) setDebug: (BOOL)flag
{
_debug = flag;
}
- (void) startLoading - (void) startLoading
{ {
static NSDictionary *methods = nil; static NSDictionary *methods = nil;
@ -579,7 +586,7 @@ static NSURLProtocol *placeholder = nil;
_statusCode = 0; /* No status returned yet. */ _statusCode = 0; /* No status returned yet. */
_isLoading = YES; _isLoading = YES;
_complete = NO; _complete = NO;
_debug = NO; _debug = GSDebugSet(@"NSHTTPURLProtocol");
/* Perform a redirect if the path is empty. /* Perform a redirect if the path is empty.
* As per MacOs-X documentation. * As per MacOs-X documentation.
@ -663,7 +670,8 @@ static NSURLProtocol *placeholder = nil;
{ {
if (_debug == YES) if (_debug == YES)
{ {
NSLog(@"did not create streams for %@:%@", host, [url port]); NSLog(@"%@ did not create streams for %@:%@",
self, host, [url port]);
} }
[self stopLoading]; [self stopLoading];
[this->client URLProtocol: self didFailWithError: [this->client URLProtocol: self didFailWithError:
@ -706,7 +714,7 @@ static NSURLProtocol *placeholder = nil;
{ {
if (_debug == YES) if (_debug == YES)
{ {
NSLog(@"stopLoading: %@", self); NSLog(@"%@ stopLoading", self);
} }
_isLoading = NO; _isLoading = NO;
DESTROY(_writeData); DESTROY(_writeData);
@ -744,7 +752,7 @@ static NSURLProtocol *placeholder = nil;
e = [stream streamError]; e = [stream streamError];
if (_debug) if (_debug)
{ {
NSLog(@"receive error %@", e); NSLog(@"%@ receive error %@", self, e);
} }
[self stopLoading]; [self stopLoading];
[this->client URLProtocol: self didFailWithError: e]; [this->client URLProtocol: self didFailWithError: e];
@ -753,7 +761,8 @@ static NSURLProtocol *placeholder = nil;
} }
if (_debug) if (_debug)
{ {
NSLog(@"Read %d bytes: '%*.*s'", readCount, readCount, readCount, buffer); NSLog(@"%@ read %d bytes: '%*.*s'",
self, readCount, readCount, readCount, buffer);
} }
if (_parser == nil) if (_parser == nil)
@ -767,7 +776,7 @@ static NSURLProtocol *placeholder = nil;
{ {
if (_debug == YES) if (_debug == YES)
{ {
NSLog(@"HTTP parse failure - %@", _parser); NSLog(@"%@ HTTP parse failure - %@", self, _parser);
} }
e = [NSError errorWithDomain: @"parse error" e = [NSError errorWithDomain: @"parse error"
code: 0 code: 0
@ -1155,7 +1164,7 @@ static NSURLProtocol *placeholder = nil;
*/ */
if (_debug == YES) if (_debug == YES)
{ {
NSLog(@"HTTP response not received - %@", _parser); NSLog(@"%@ HTTP response not received - %@", self, _parser);
} }
[self stopLoading]; [self stopLoading];
[this->client URLProtocol: self didFailWithError: [this->client URLProtocol: self didFailWithError:
@ -1188,7 +1197,7 @@ static NSURLProtocol *placeholder = nil;
case NSStreamEventOpenCompleted: case NSStreamEventOpenCompleted:
if (_debug == YES) if (_debug == YES)
{ {
NSLog(@"HTTP input stream opened"); NSLog(@"%@ HTTP input stream opened", self);
} }
return; return;
@ -1211,7 +1220,7 @@ static NSURLProtocol *placeholder = nil;
if (_debug == YES) if (_debug == YES)
{ {
NSLog(@"HTTP output stream opened"); NSLog(@"%@ HTTP output stream opened", self);
} }
DESTROY(_writeData); DESTROY(_writeData);
_writeOffset = 0; _writeOffset = 0;
@ -1298,7 +1307,7 @@ static NSURLProtocol *placeholder = nil;
{ {
if (_debug == YES) if (_debug == YES)
{ {
NSLog(@"Wrote %d bytes: '%*.*s'", written, NSLog(@"%@ wrote %d bytes: '%*.*s'", self, written,
written, written, bytes + _writeOffset); written, written, bytes + _writeOffset);
} }
_writeOffset += written; _writeOffset += written;
@ -1339,8 +1348,8 @@ static NSURLProtocol *placeholder = nil;
{ {
if (_debug == YES) if (_debug == YES)
{ {
NSLog(@"error reading from HTTPBody stream %@", NSLog(@"%@ error reading from HTTPBody stream %@",
[NSError _last]); self, [NSError _last]);
} }
[self stopLoading]; [self stopLoading];
[this->client URLProtocol: self didFailWithError: [this->client URLProtocol: self didFailWithError:
@ -1356,8 +1365,8 @@ static NSURLProtocol *placeholder = nil;
{ {
if (_debug == YES) if (_debug == YES)
{ {
NSLog(@"Wrote %d bytes: '%*.*s'", written, NSLog(@"%@ wrote %d bytes: '%*.*s'", self,
written, written, buffer); written, written, written, buffer);
} }
len -= written; len -= written;
if (len > 0) if (len > 0)
@ -1389,7 +1398,7 @@ static NSURLProtocol *placeholder = nil;
{ {
if (_debug) if (_debug)
{ {
NSLog(@"request sent"); NSLog(@"%@ request sent", self);
} }
if (_shouldClose == YES) if (_shouldClose == YES)
{ {