mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-01 09:02:01 +00:00
Make debug trace be per
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@11615 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
32a645b6bd
commit
e33461857f
1 changed files with 22 additions and 10 deletions
|
@ -41,7 +41,6 @@
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
|
|
||||||
static NSString *httpVersion = @"1.1";
|
static NSString *httpVersion = @"1.1";
|
||||||
static BOOL debug = NO;
|
|
||||||
|
|
||||||
char emp[64] = {
|
char emp[64] = {
|
||||||
'A','B','C','D','E','F','G','H','I','J','K','L','M',
|
'A','B','C','D','E','F','G','H','I','J','K','L','M',
|
||||||
|
@ -54,6 +53,7 @@ char emp[64] = {
|
||||||
@interface GSHTTPURLHandle : NSURLHandle
|
@interface GSHTTPURLHandle : NSURLHandle
|
||||||
{
|
{
|
||||||
BOOL tunnel;
|
BOOL tunnel;
|
||||||
|
BOOL debug;
|
||||||
NSFileHandle *sock;
|
NSFileHandle *sock;
|
||||||
NSURL *url;
|
NSURL *url;
|
||||||
NSMutableData *dat;
|
NSMutableData *dat;
|
||||||
|
@ -72,6 +72,7 @@ char emp[64] = {
|
||||||
} connectionState;
|
} connectionState;
|
||||||
}
|
}
|
||||||
- (NSString*) encodebase64: (NSString*) input;
|
- (NSString*) encodebase64: (NSString*) input;
|
||||||
|
- (void) setDebug: (BOOL)flag;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,11 +81,16 @@ char emp[64] = {
|
||||||
static NSMutableDictionary *urlCache = nil;
|
static NSMutableDictionary *urlCache = nil;
|
||||||
static NSLock *urlLock = nil;
|
static NSLock *urlLock = nil;
|
||||||
|
|
||||||
|
static NSLock *debugLock = nil;
|
||||||
|
static char debugFile[128];
|
||||||
|
|
||||||
static void debugRead(NSData *data)
|
static void debugRead(NSData *data)
|
||||||
{
|
{
|
||||||
NSString *s = [NSString stringWithFormat: @"/tmp/GSHTTP.%d", getpid()];
|
NSString *s;
|
||||||
int d = open([s cString], O_WRONLY|O_CREAT|O_APPEND, 0644);
|
int d;
|
||||||
|
|
||||||
|
[debugLock lock];
|
||||||
|
d = open(debugFile, O_WRONLY|O_CREAT|O_APPEND, 0644);
|
||||||
if (d >= 0)
|
if (d >= 0)
|
||||||
{
|
{
|
||||||
s = [NSString stringWithFormat: @"\nRead %@ -\n", [NSDate date]];
|
s = [NSString stringWithFormat: @"\nRead %@ -\n", [NSDate date]];
|
||||||
|
@ -92,12 +98,15 @@ static void debugRead(NSData *data)
|
||||||
write(d, [data bytes], [data length]);
|
write(d, [data bytes], [data length]);
|
||||||
close(d);
|
close(d);
|
||||||
}
|
}
|
||||||
|
[debugLock unlock];
|
||||||
}
|
}
|
||||||
static void debugWrite(NSData *data)
|
static void debugWrite(NSData *data)
|
||||||
{
|
{
|
||||||
NSString *s = [NSString stringWithFormat: @"/tmp/GSHTTP.%d", getpid()];
|
NSString *s;
|
||||||
int d = open([s cString], O_WRONLY|O_CREAT|O_APPEND, 0644);
|
int d;
|
||||||
|
|
||||||
|
[debugLock lock];
|
||||||
|
d = open(debugFile, O_WRONLY|O_CREAT|O_APPEND, 0644);
|
||||||
if (d >= 0)
|
if (d >= 0)
|
||||||
{
|
{
|
||||||
s = [NSString stringWithFormat: @"\nWrite %@ -\n", [NSDate date]];
|
s = [NSString stringWithFormat: @"\nWrite %@ -\n", [NSDate date]];
|
||||||
|
@ -105,6 +114,7 @@ static void debugWrite(NSData *data)
|
||||||
write(d, [data bytes], [data length]);
|
write(d, [data bytes], [data length]);
|
||||||
close(d);
|
close(d);
|
||||||
}
|
}
|
||||||
|
[debugLock unlock];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSURLHandle*) cachedHandleForURL: (NSURL*)newUrl
|
+ (NSURLHandle*) cachedHandleForURL: (NSURL*)newUrl
|
||||||
|
@ -131,14 +141,11 @@ static void debugWrite(NSData *data)
|
||||||
{
|
{
|
||||||
urlCache = [NSMutableDictionary new];
|
urlCache = [NSMutableDictionary new];
|
||||||
urlLock = [NSLock new];
|
urlLock = [NSLock new];
|
||||||
|
debugLock = [NSLock new];
|
||||||
|
sprintf(debugFile, "/tmp/GSHTTP.%d", getpid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (void) setDebug: (BOOL)flag
|
|
||||||
{
|
|
||||||
debug = flag;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
RELEASE(sock);
|
RELEASE(sock);
|
||||||
|
@ -688,6 +695,11 @@ static void debugWrite(NSData *data)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) setDebug: (BOOL)flag
|
||||||
|
{
|
||||||
|
debug = flag;
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL) writeData: (NSData*)d
|
- (BOOL) writeData: (NSData*)d
|
||||||
{
|
{
|
||||||
ASSIGN(wData, d);
|
ASSIGN(wData, d);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue