keep old format if there are no nul bytes to print

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@38947 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2015-08-29 20:25:16 +00:00
parent 574c83e0bf
commit f22f51b4e5

View file

@ -232,19 +232,43 @@ static void
debugRead(GSHTTPURLHandle *handle, NSData *data)
{
unsigned len = (unsigned)[data length];
char *esc = [data escapedRepresentation: 0];
const char *ptr = (const char*)[data bytes];
int pos;
NSLog(@"Read for %p of %u bytes - '%s'\n%@", handle, len, esc, data);
free(esc);
for (pos = 0; pos < len; pos++)
{
if (0 == ptr[pos])
{
char *esc = [data escapedRepresentation: 0];
NSLog(@"Read for %p of %u bytes (escaped) - '%s'\n%@",
handle, len, esc, data);
free(esc);
return;
}
}
NSLog(@"Read for %p of %d bytes - '%*.*s'", handle, len, len, len, ptr);
}
static void
debugWrite(GSHTTPURLHandle *handle, NSData *data)
{
unsigned len = (unsigned)[data length];
char *esc = [data escapedRepresentation: 0];
const char *ptr = (const char*)[data bytes];
int pos;
NSLog(@"Write for %p of %u bytes - '%s'\n%@", handle, len, esc, data);
free(esc);
for (pos = 0; pos < len; pos++)
{
if (0 == ptr[pos])
{
char *esc = [data escapedRepresentation: 0];
NSLog(@"Write for %p of %u bytes (escaped) - '%s'\n%@",
handle, len, esc, data);
free(esc);
return;
}
}
NSLog(@"Write for %p of %d bytes - '%*.*s'", handle, len, len, len, ptr);
}
+ (NSURLHandle*) cachedHandleForURL: (NSURL*)newUrl