From: helge Date: Wed, 17 Nov 2004 00:01:54 +0000 (+0000) Subject: added support for cookies which are rooted on / X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1dff761e9e7d65c93d7e290a2cbb9eafbea700d0;p=sope added support for cookies which are rooted on / git-svn-id: http://svn.opengroupware.org/SOPE/trunk@378 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-appserver/NGObjWeb/ChangeLog b/sope-appserver/NGObjWeb/ChangeLog index 0d307ca8..30b88ec9 100644 --- a/sope-appserver/NGObjWeb/ChangeLog +++ b/sope-appserver/NGObjWeb/ChangeLog @@ -1,3 +1,10 @@ +2004-11-17 Helge Hess + + * WORequestHandler.m: added 'WOUseGlobalCookiePath' default to + configure whether the application URL (NO) or "/" (YES) should be + used as the path for the session-id cookie (related to OGo bug #914 + (v4.5.89) + 2004-11-05 Helge Hess * WOSimpleHTTPParser.m: set a default file boundary size and max upload diff --git a/sope-appserver/NGObjWeb/Defaults.plist b/sope-appserver/NGObjWeb/Defaults.plist index 78b81548..14892079 100644 --- a/sope-appserver/NGObjWeb/Defaults.plist +++ b/sope-appserver/NGObjWeb/Defaults.plist @@ -96,6 +96,7 @@ WOSimpleHTTPParserMaxUploadSizeInKB = 262144; WOStatsStylesheetName = "WOStats.xsl"; WOUseRelativeURLs = YES; + WOUseGlobalCookiePath = YES; WOValueAssociationsCacheSize = 200; WOWorkerThreadCount = 0; WOxFileExtensions = ( wox, xtmpl, xhtml ); diff --git a/sope-appserver/NGObjWeb/Version b/sope-appserver/NGObjWeb/Version index cec1772e..7a1ddcc8 100644 --- a/sope-appserver/NGObjWeb/Version +++ b/sope-appserver/NGObjWeb/Version @@ -1,6 +1,6 @@ # version file -SUBMINOR_VERSION:=88 +SUBMINOR_VERSION:=89 # v4.5.84 required libNGExtensions v4.5.127 # v4.3.42 requires libNGExtensions v4.3.116 diff --git a/sope-appserver/NGObjWeb/WOApplication.m b/sope-appserver/NGObjWeb/WOApplication.m index 7dafabd1..85b496d2 100644 --- a/sope-appserver/NGObjWeb/WOApplication.m +++ b/sope-appserver/NGObjWeb/WOApplication.m @@ -511,18 +511,18 @@ static NSString *rapidTurnAroundPath = nil; if (_request == nil) return nil; /* first look into form values */ - if ((sessionId = [_request formValueForKey:WORequestValueSessionID])) { + if ((sessionId = [_request formValueForKey:WORequestValueSessionID])!=nil) { if ([sessionId length] > 0) return sessionId; } /* now look into the cookies */ - if ((sessionId = [_request cookieValueForKey:[self name]])) { + if ((sessionId = [_request cookieValueForKey:[self name]]) != nil) { if ([sessionId respondsToSelector:@selector(objectEnumerator)]) { NSEnumerator *e; e = [(id)sessionId objectEnumerator]; - while ((sessionId = [e nextObject])) { + while ((sessionId = [e nextObject]) != nil) { if ([sessionId length] > 0 && ![sessionId isEqual:@"nil"]) return sessionId; } diff --git a/sope-appserver/NGObjWeb/WORequestHandler.m b/sope-appserver/NGObjWeb/WORequestHandler.m index faccd753..78cc2935 100644 --- a/sope-appserver/NGObjWeb/WORequestHandler.m +++ b/sope-appserver/NGObjWeb/WORequestHandler.m @@ -46,6 +46,7 @@ @implementation WORequestHandler +static BOOL doNotSetCookiePath = NO; static BOOL perflog = NO; static Class NSDateClass = Nil; @@ -53,18 +54,19 @@ static Class NSDateClass = Nil; return 2; } + (void)initialize { + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + NSDateClass = [NSDate class]; - perflog = [[NSUserDefaults standardUserDefaults] - boolForKey:@"WOProfileRequestHandler"]; + perflog = [ud boolForKey:@"WOProfileRequestHandler"]; + doNotSetCookiePath = [ud boolForKey:@"WOUseGlobalCookiePath"]; } - (id)init { if ((self = [super init])) { - if ([[[NSUserDefaults standardUserDefaults] - objectForKey:@"WORunMultithreaded"] - boolValue]) { + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + + if ([ud boolForKey:@"WORunMultithreaded"]) self->lock = [[NSRecursiveLock alloc] init]; - } } return self; } @@ -188,7 +190,7 @@ static Class NSDateClass = Nil; [[session retain] autorelease]; - if (response) + if (response != nil) /* some kind of error response from above ... */ goto responseDone; @@ -232,12 +234,13 @@ static Class NSDateClass = Nil; session:session application:app]; - session = ([context hasSession]) + session = [context hasSession] ? [context session] : nil; - if (session) { + if (session != nil) { if ([session storesIDsInCookies]) { + [self logInfoWithFormat:@"add cookie to session: %@", session]; [self addCookiesForSession:session toResponse:response inContext:context]; @@ -248,6 +251,8 @@ static Class NSDateClass = Nil; withResponse:response application:app]; } + else + [self logInfoWithFormat:@"no session to store."]; } NS_HANDLER { response = [app handleException:localException inContext:context]; @@ -329,17 +334,18 @@ static Class NSDateClass = Nil; app = [WOApplication application]; cookieName = [app name]; - { + if (!doNotSetCookiePath) { NSString *tmp; if ((uri = [[_ctx request] applicationName]) == nil) uri = [app name]; uri = [@"/" stringByAppendingString:uri]; - if ((tmp = [[_ctx request] adaptorPrefix])) uri = [tmp stringByAppendingString:uri]; } - + else + uri = @"/"; + #if 0 uri = [_ctx urlSessionPrefix]; uri = [_ctx urlWithRequestHandlerKey: @@ -429,7 +435,7 @@ static Class NSDateClass = Nil; [_app saveSessionForContext:_ctx]; /* store response if strange double-click browser */ - if (_response) { + if (_response != nil) { if ([[_ctx request] isDoubleClickBrowser]) { NSArray *hack; /* 0: uri, 1: response */