From: helge Date: Fri, 19 Nov 2004 01:23:30 +0000 (+0000) Subject: cleaned up cookie handling X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e2004031892faf393ecdedb34530f4e55f12a2db;p=sope cleaned up cookie handling git-svn-id: http://svn.opengroupware.org/SOPE/trunk@398 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-appserver/NGObjWeb/ChangeLog b/sope-appserver/NGObjWeb/ChangeLog index e1b2122b..2b5fad2f 100644 --- a/sope-appserver/NGObjWeb/ChangeLog +++ b/sope-appserver/NGObjWeb/ChangeLog @@ -1,5 +1,11 @@ 2004-11-19 Helge Hess + * v4.5.94 + + * NGHttp+WO.m: minor improvements to cookie handling + + * WORequestHandler.m: cleaned up cookie adder + * v4.5.93 * WOApplication.m: print a note if debug logging is enabled diff --git a/sope-appserver/NGObjWeb/NGHttp+WO.m b/sope-appserver/NGObjWeb/NGHttp+WO.m index 3e83d4fc..0c06a98c 100644 --- a/sope-appserver/NGObjWeb/NGHttp+WO.m +++ b/sope-appserver/NGObjWeb/NGHttp+WO.m @@ -195,34 +195,34 @@ static Class NSArrayClass = Nil; return; } - - cookieValue = [_cookie value]; - if ([cookieValue isKindOfClass:[NSArray class]]) { - if ([cookieValue count] == 0) - cookieValue = @""; - else if ([cookieValue count] == 1) - cookieValue = [[cookieValue objectAtIndex:0] stringValue]; - else { - [self logWithFormat: - @"got %i values for cookie '%@', using first only.", - [cookieValue count], - [_cookie cookieName]]; - cookieValue = [[cookieValue objectAtIndex:0] stringValue]; - } + cookieValue = [_cookie value]; + if ([cookieValue isKindOfClass:[NSArray class]]) { + if ([cookieValue count] == 0) + cookieValue = @""; + else if ([cookieValue count] == 1) + cookieValue = [[cookieValue objectAtIndex:0] stringValue]; + else { + [self logWithFormat: + @"got %d values for cookie '%@', using first only: %@", + [cookieValue count], + [_cookie cookieName], + [cookieValue componentsJoinedByString:@","]]; + cookieValue = [[cookieValue objectAtIndex:0] stringValue]; } - else - cookieValue = [cookieValue stringValue]; + } + else + cookieValue = [cookieValue stringValue]; - cookie = [WOCookieClass cookieWithName:[_cookie cookieName] - value:cookieValue - path:[_cookie path] - domain:[_cookie domainName] - expires:[_cookie expireDate] - isSecure:[_cookie needsSecureChannel]]; - - /* WOMessage */ - if (cookie) - [_a addObject:cookie]; + cookie = [WOCookieClass cookieWithName:[_cookie cookieName] + value:cookieValue + path:[_cookie path] + domain:[_cookie domainName] + expires:[_cookie expireDate] + isSecure:[_cookie needsSecureChannel]]; + + /* WOMessage */ + if (cookie != nil) + [_a addObject:cookie]; } - (NSArray *)woCookies { @@ -421,7 +421,9 @@ static Class DispClass = Nil; if ([[self methodName] isEqualToString:@"POST"]) { NGMimeType *contentType = [self contentType]; - //NSLog(@"%s: process POST, ctype %@", __PRETTY_FUNCTION__, contentType); +#if 0 + NSLog(@"%s: process POST, ctype %@", __PRETTY_FUNCTION__, contentType); +#endif formContent = [contentType hasSameType:multipartFormData] ? [self _decodeMultiPartFormDataContent] diff --git a/sope-appserver/NGObjWeb/NGHttp/NGHttpRequest.m b/sope-appserver/NGObjWeb/NGHttp/NGHttpRequest.m index cc9ff0f8..9bc431c4 100644 --- a/sope-appserver/NGObjWeb/NGHttp/NGHttpRequest.m +++ b/sope-appserver/NGObjWeb/NGHttp/NGHttpRequest.m @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #include "NGHttpRequest.h" #include "common.h" diff --git a/sope-appserver/NGObjWeb/Version b/sope-appserver/NGObjWeb/Version index 83d96028..625a9567 100644 --- a/sope-appserver/NGObjWeb/Version +++ b/sope-appserver/NGObjWeb/Version @@ -1,6 +1,6 @@ # version file -SUBMINOR_VERSION:=93 +SUBMINOR_VERSION:=94 # v4.5.91 requires libNGExtensions v4.5.134 # v4.5.84 requires libNGExtensions v4.5.127 diff --git a/sope-appserver/NGObjWeb/WORequestHandler.m b/sope-appserver/NGObjWeb/WORequestHandler.m index 88866feb..ac3e8fe8 100644 --- a/sope-appserver/NGObjWeb/WORequestHandler.m +++ b/sope-appserver/NGObjWeb/WORequestHandler.m @@ -339,49 +339,50 @@ static NGLogger *perfLogger = nil; toResponse:(WOResponse *)_response inContext:(WOContext *)_ctx { - if ([_sn storesIDsInCookies]) { - WOApplication *app; - NSString *cookieName = nil; - WOCookie *cookie = nil; - NSString *uri; - NSString *value; - - app = [WOApplication application]; - cookieName = [app name]; - - if (!doNotSetCookiePath) { - NSString *tmp; + WOApplication *app; + WOCookie *cookie = nil; + NSString *uri; + NSString *value; + + if (![_sn storesIDsInCookies]) + return; + + app = [WOApplication application]; + + // TODO: there is a DUP of this section in OpenGroupware.m to set an + // expiration cookie + 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: - [WOApplication componentRequestHandlerKey] - path:@"/" - queryString:nil]; + 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 // TODO: explain! + uri = [_ctx urlSessionPrefix]; + uri = [_ctx urlWithRequestHandlerKey: + [WOApplication componentRequestHandlerKey] + path:@"/" + queryString:nil]; #endif - value = [_sn isTerminating] - ? (id)@"nil" - : [_sn sessionID]; + value = [_sn isTerminating] + ? (id)@"nil" + : [_sn sessionID]; - cookie = [WOCookie cookieWithName:cookieName - value:value - path:uri - domain:[_sn domainForIDCookies] - expires:[_sn expirationDateForIDCookies] - isSecure:NO]; - if (cookie) - [_response addCookie:cookie]; - } + cookie = [WOCookie cookieWithName:[app name] + value:value + path:uri + domain:[_sn domainForIDCookies] + expires:[_sn expirationDateForIDCookies] + isSecure:NO]; + if (cookie != nil) + [_response addCookie:cookie]; } @end /* WORequestHandler(Cookies) */ diff --git a/sope-core/NGExtensions/NGExtensions/NSObject+Logs.h b/sope-core/NGExtensions/NGExtensions/NSObject+Logs.h index a973a620..58831a1f 100644 --- a/sope-core/NGExtensions/NGExtensions/NSObject+Logs.h +++ b/sope-core/NGExtensions/NGExtensions/NSObject+Logs.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2004 SKYRIX Software AG + Copyright (C) 2004 SKYRIX Software AG This file is part of OpenGroupware.org