+2006-05-04 Helge Hess <helge.hess@opengroupware.org>
+
+ * v4.5.230
+
+ * WebDAV/SoObjectWebDAVDispatcher.m: added default
+ 'SoWebDAVDisableCrossHostMoveCheck' to disable the check for the
+ hostname on WebDAV MOVE/COPY operations. This can give issues when
+ Apache is accessed with different DNS names or IPs.
+
+ * WOHttpAdaptor/WOHttpTransaction.m: log HTTP request size after
+ response size
+
2006-05-01 Helge Hess <helge.hess@opengroupware.org>
* v4.5.229
);
SoWebDAVFormatOutput = NO;
DAVParserDebugProp = NO;
-
+
+ SoWebDAVDisableCrossHostMoveCheck = NO;
+
SoWebDAVDefaultAllowMethods = (
GET, HEAD, POST, OPTIONS, MKCOL, DELETE, PUT,
LOCK, UNLOCK, COPY, MOVE
# version file
-SUBMINOR_VERSION:=229
+SUBMINOR_VERSION:=230
# v4.5.214 requires libNGExtensions v4.5.179
# v4.5.122 requires libNGExtensions v4.5.153
if (self->woResponse == nil)
return;
- [self logResponse:self->woResponse
- toRequest:self->woRequest
+ [self logResponse:self->woResponse toRequest:self->woRequest
connection:self->socket];
if (perfLogger) {
rt < 0.0 ? -1.0 : rt];
}
- if (self->woResponse) {
+ if (self->woResponse != nil) {
[self deliverResponse:self->woResponse
toRequest:self->woRequest
onStream:self->io];
rt < 0.0 ? -1.0 : rt];
}
}
- else if (self->woRequest) {
+ else if (self->woRequest != nil) {
[self errorWithFormat:@"got no response for request %@ ..",
self->woRequest];
rlen = strlen((const char *)r);
if ((slen + rlen + 8) < 1000) {
[t1 getCString:(char *)buf];
- sprintf((char *)&(buf[slen]), " %i %s\r\n", s, r);
+ snprintf((char *)&(buf[slen]), sizeof(buf), " %i %s\r\n", s, r);
isok = [_out safeWriteBytes:buf count:strlen((char *)buf)];
}
else
/* add content length header */
- sprintf((char *)buf, "%d", [body length]);
+ snprintf((char *)buf, sizeof(buf), "%d", [body length]);
t1 = [[NSString alloc] initWithCString:(char *)buf];
[_response setHeader:t1 forKey:@"content-length"];
[t1 release]; t1 = nil;
Profiling: this method takes 0.95% of -run if the output is piped to
/dev/null on OSX, morphing caldate to string is 0.79% of that.
*/
+ static BOOL doExtLog = YES;
NSString *remoteHost;
NSNumber *zippedLen;
NSCalendarDate *now;
[buf appendString:@" "];
[buf appendString:[_request httpVersion]];
[buf appendString:@"\" "];
- [buf appendFormat:@"%i", [_response status]];
- [buf appendFormat:@" %i", [[_response content] length]];
-
+ [buf appendFormat:@"%i %i",
+ [_response status],
+ [[_response content] length]];
+ if (doExtLog)
+ [buf appendFormat:@"/%i", [[_request content] length]];
+
/* append duration */
- if (lstartDate)
+ if (lstartDate != nil)
[buf appendFormat:@" %.3f", [now timeIntervalSinceDate:lstartDate]];
else
[buf appendString:@" -"];
@implementation WORecordRequestStream
- (id)initWithSource:(id<NGStream>)_source {
- if ((self = [super initWithSource:_source])) {
+ if ((self = [super initWithSource:_source]) != nil) {
self->readLog = [[NSMutableData alloc] initWithCapacity:ReadLogInitSize];
self->writeLog = [[NSMutableData alloc] initWithCapacity:WriteLogInitSize];
}
if (gmt == nil)
gmt = [[NSTimeZone timeZoneWithAbbreviation:@"GMT"] retain];
-
+
runMultithreaded = [[NSUserDefaults standardUserDefaults]
- boolForKey:@"WORunMultithreaded"];
+ boolForKey:@"WORunMultithreaded"];
}
- (id)init {
return [NSNumberClass numberWithUnsignedInt:i];
}
static id mkdbl(double d) {
-#if 1
+#if 1 // TODO: why is that?
char buf[64];
sprintf(buf, "%.3f", d);
return [NSStringClass stringWithCString:buf];
if (pageStats->totalResponseCount > 0) {
[stats setObject:
- mkuint(pageStats->totalResponseSize / pageStats->totalResponseCount)
+ mkuint(pageStats->totalResponseSize/pageStats->totalResponseCount)
forKey:@"averageResponseSize"];
[stats setObject:
mkdbl(pageStats->totalDuration / pageStats->totalResponseCount)
static int debugOn = -1;
static BOOL debugBulkTarget = NO;
+static BOOL disableCrossHostMoveCheck = NO;
static NSNumber *yesNum = nil;
+ (void)initialize {
debugOn = [ud boolForKey:@"SoObjectDAVDispatcherDebugEnabled"] ? 1 : 0;
if (debugOn) NSLog(@"Note: WebDAV dispatcher debugging is enabled.");
if (yesNum == nil) yesNum = [[NSNumber numberWithBool:YES] retain];
+
+ disableCrossHostMoveCheck =
+ [ud boolForKey:@"SoWebDAVDisableCrossHostMoveCheck"];
}
// THREAD
pathInfo, delProps, setProps];
}
- if ([pathInfo length] == 0) {
+ if (![pathInfo isNotEmpty]) {
/* edit an object */
NSException *e;
/*
The WebDAV spec is not really clear on what we should return in this
case? Let me know if anybody has a suggestion ...
+
+ Note: This is easy to confuse if you don't use the Apache server name
+ to access Apache (eg just the IP). Which is why we allow to
+ disable this check.
*/
[self logWithFormat:@"tried to do a cross server move (%@ vs %@)",
[srvURL absoluteString], [destURL absoluteString]];
- return [self httpException:403 /* Forbidden */
- reason:@"MOVE destination is on a different host."];
+ if (!disableCrossHostMoveCheck) {
+ return [self httpException:403 /* Forbidden */
+ reason:@"MOVE destination is on a different host."];
+ }
}
- if (path_) {
+ if (path_ != NULL) {
NSMutableArray *ma;
unsigned i;
/* TODO: hack hack hack */
ma = [[[destURL path] componentsSeparatedByString:@"/"] mutableCopy];
- if ([ma count] > 0) // leading slash ("")
+ if ([ma isNotEmpty]) // leading slash ("")
[ma removeObjectAtIndex:0];
- if ([ma count] > 0) // the appname (eg zidestore)
+ if ([ma isNotEmpty]) // the appname (eg zidestore)
[ma removeObjectAtIndex:0];
- if ([ma count] > 0) // the request handler key (eg so)
+ if ([ma isNotEmpty]) // the request handler key (eg so)
[ma removeObjectAtIndex:0];
/* unescape path components */
for (i = 0; i < [ma count]; i++) {
- NSString *s = [ma objectAtIndex:i], *ns;
+ NSString *s, *ns;
+ s = [ma objectAtIndex:i];
ns = [s stringByUnescapingURL];
if (ns != s)
[ma replaceObjectAtIndex:i withObject:ns];