/*
- Copyright (C) 2000-2005 SKYRIX Software AG
+ Copyright (C) 2000-2008 SKYRIX Software AG
+ Copyright (C) 2008 Helge Hess
This file is part of SOPE.
@"delivering of response failed with exception: %@";
*(&out) = nil;
-
+
[self _httpValidateResponse:_response];
out = [(NGCTextStream *)[NGCTextStream alloc] initWithSource:_out];
s = [_response status];
t1 = [_response httpVersion];
r = [self _reasonForStatus:s];
-
+
+ // TBD: replace -cStringLength/-getCString:
slen = [t1 cStringLength];
rlen = strlen((const char *)r);
if ((slen + rlen + 8) < 1000) {
- [t1 getCString:(char *)buf];
+ [t1 getCString:(char *)buf]; // HTTP status
snprintf((char *)&(buf[slen]), sizeof(buf), " %i %s\r\n", s, r);
isok = [_out safeWriteBytes:buf count:strlen((char *)buf)];
}
BOOL hasConnectionHeader;
IMP addStr;
+#if HEAVY_DEBUG
+ NSLog(@"DELIVER: %@", _response);
+#endif
+
hasConnectionHeader = NO;
header = [[NSMutableString alloc] initWithCapacity:4096];
addStr = [header methodForSelector:@selector(appendString:)];
hasConnectionHeader = YES;
}
+#if HEAVY_DEBUG
+ NSLog(@" FIELD: %@", fieldName);
+#endif
+
values = [[_response headersForKey:fieldName] objectEnumerator];
while ((value = [values nextObject]) && isok) {
+#if HEAVY_DEBUG
+ NSLog(@" VAL: %@", value);
+#endif
addStr(header, @selector(appendString:), fieldName);
addStr(header, @selector(appendString:), @": ");
addStr(header, @selector(appendString:), value);
addStr(header, @selector(appendString:), @"\r\n");
}
+#if HEAVY_DEBUG
+ NSLog(@" END: %@", fieldName);
+#endif
}
+
+#if HEAVY_DEBUG
+ NSLog(@" HEADER:\n%@", header);
+ NSLog(@" OUT: %@", out);
+#endif
isok = [out writeString:header];
- [header release];
+ [header release]; header = nil;
#if 0
#warning TODO: experimental, need to check for direct connect
isok = [out writeString:@"connection: close\r\n"];
#endif
}
+#if HEAVY_DEBUG
+ else {
+ NSLog(@"NOT OK TO DELIVER HEADERS ...");
+ }
+#endif
/* write cookie headers */
if (isok) {