Optimizations, fixes and disabling sesson creation/restoration feature

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@21051 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Manuel Guesdon 2005-04-05 14:49:55 +00:00
parent a70d649ad1
commit f2d2a684ab
7 changed files with 334 additions and 142 deletions

View file

@ -1,3 +1,33 @@
2005-04-05 Manuel Guesdon <mguesdon@orange-concept.com>
* GSWeb.framework/GSWContext.m:
o add contextAndElementID caching and optimizations
o use GSWIntToNSString instead of -stringWithFormat:
o fix for https in
-directActionURLForActionNamed:urlPrefix:queryDictionary:
-directActionURLForActionNamed:urlPrefix:queryDictionary:pathQueryDictionary:
-componentActionURL
-urlWithURLPrefix:requestHandlerKey:path:queryString:
-urlWithRequestHandlerKey:path:queryString:
-_directActionURLForActionNamed:urlPrefix:queryDictionary:pathQueryDictionary:url:
o avoid stringWithFormat int -componentActionURLIsSecure:
o optimization in
_directActionURLForActionNamed:urlPrefix:queryDictionary:pathQueryDictionary:isSecure:
o fix in -languages session addressing
o added -isSessionDisabled, -setIsSessionDisabled: methods
and _isSessionDisabled ivar to disable session creation/restoration
* GSWeb.framework/GSWContext.h:
o added _contextAndElementIDIMP in GSWContextIMPs
o added GSWContext_contextAndElementID()
* GSWeb.framework/GSWAction.m:
o handle context isSessionDisabled
o avoid string formatting
* GSWeb.framework/GSWBundle.m:
o use standard methods to build pathes and file names
* GSWeb.framework/GSWActionRequestHandler.m:
o avoid string formatting
* GSWeb.framework/GSWPrivate.h:
o avoid calling method if string parameter is nil
2005-04-05 Manuel Guesdon <mguesdon@orange-concept.com>
* GSWExtensions.framework/Makefile.preamble:
o handle GSWDEBUG in Makefile.preamble

View file

@ -1,6 +1,6 @@
/** GSWAction.m - <title>GSWeb: Class GSWAction</title>
Copyright (C) 1999-2004 Free Software Foundation, Inc.
Copyright (C) 1999-2005 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Feb 1999
@ -70,34 +70,41 @@ RCS_ID("$Id$")
//OK
GSWSession* session=nil;
BOOL hasSession=NO;
LOGObjectFnStart();
hasSession=[_context hasSession];
if (hasSession)
session=[_context existingSession];
if (!session)
if (![_context isSessionDisabled])
{
NSString* sessionID=nil;
sessionID=[[self request] sessionID];
if (sessionID)
hasSession=[_context hasSession];
if (hasSession)
session=[_context existingSession];
if (!session)
{
NS_DURING
NSString* sessionID=nil;
sessionID=[[self request] sessionID];
if (sessionID)
{
NSDebugMLLog(@"requests",@"sessionID=%@",sessionID);
session=[GSWApp restoreSessionWithID:sessionID
inContext:_context];
//No Exception if session can't be restored !
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,@"in session create/restore");
LOGException(@"exception=%@",localException);
//No Exception if session can't be restored !
session=nil;
}
NS_ENDHANDLER;
NS_DURING
{
NSDebugMLLog(@"requests",@"sessionID=%@",sessionID);
session=[GSWApp restoreSessionWithID:sessionID
inContext:_context];
//No Exception if session can't be restored !
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,@"in session create/restore");
LOGException(@"exception=%@",localException);
//No Exception if session can't be restored !
session=nil;
}
NS_ENDHANDLER;
};
};
};
LOGObjectFnStop();
return session;
};
@ -107,32 +114,39 @@ RCS_ID("$Id$")
//OK
GSWSession* session=nil;
BOOL hasSession=NO;
LOGObjectFnStart();
hasSession=[_context hasSession];
if (hasSession)
session=[_context existingSession];
if (!session)
if (![_context isSessionDisabled])
{
if (aSessionID)
hasSession=[_context hasSession];
if (hasSession)
session=[_context existingSession];
if (!session)
{
NS_DURING
if (aSessionID)
{
NSDebugMLLog(@"requests",@"aSessionID=%@",aSessionID);
session=[GSWApp restoreSessionWithID:aSessionID
inContext:_context];
//No Exception if session can't be restored !
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,@"in session create/restore");
LOGException(@"exception=%@",localException);
//No Exception if session can't be restored !
session=nil;
}
NS_ENDHANDLER;
NS_DURING
{
NSDebugMLLog(@"requests",@"aSessionID=%@",aSessionID);
session=[GSWApp restoreSessionWithID:aSessionID
inContext:_context];
//No Exception if session can't be restored !
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,@"in session create/restore");
LOGException(@"exception=%@",localException);
//No Exception if session can't be restored !
session=nil;
}
NS_ENDHANDLER;
};
};
};
LOGObjectFnStop();
return session;
};
@ -141,42 +155,49 @@ RCS_ID("$Id$")
{
BOOL hasSession=NO;
GSWSession* session=nil;
LOGObjectFnStart();
hasSession=[_context hasSession];
if (hasSession)
session=[_context existingSession];
if (!session)
if (![_context isSessionDisabled])
{
NSString* sessionID=nil;
sessionID=[[self request] sessionID];
if (sessionID)
hasSession=[_context hasSession];
if (hasSession)
session=[_context existingSession];
if (!session)
{
NS_DURING
NSString* sessionID=nil;
sessionID=[[self request] sessionID];
if (sessionID)
{
session=[GSWApp restoreSessionWithID:sessionID
inContext:_context];
NS_DURING
{
session=[GSWApp restoreSessionWithID:sessionID
inContext:_context];
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,@"in session create/restore");
LOGException(@"exception=%@",localException);
[localException raise];
};
NS_ENDHANDLER;
if (!session)
{
ExceptionRaise(@"GSWAction",
@"Unable to restore sessionID %@.",
sessionID);
};
}
NS_HANDLER
else
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,@"in session create/restore");
LOGException(@"exception=%@",localException);
[localException raise];
// No Session ID: Create a new Session
session=[_context session];
};
NS_ENDHANDLER;
if (!session)
{
ExceptionRaise(@"GSWAction",
@"Unable to restore sessionID %@.",
sessionID);
};
}
else
{
// No Session ID: Create a new Session
session=[_context session];
};
};
LOGObjectFnStop();
return session;
};
@ -227,7 +248,7 @@ RCS_ID("$Id$")
{
NSString* actionSelName=nil;
SEL actionSel=NULL;
actionSelName=[NSString stringWithFormat:@"%@Action",actionName];
actionSelName=[actionName stringByAppendingString:@"Action"];
NSDebugMLLog(@"requests",@"actionSelName=%@",actionSelName);
actionSel=NSSelectorFromString(actionSelName);
return actionSel;
@ -332,7 +353,7 @@ RCS_ID("$Id$")
//--------------------------------------------------------------------
-(void)logWithString:(NSString*)string
{
[GSWApplication logWithFormat:@"%@",string];
[GSWApplication logString:string];
};
//--------------------------------------------------------------------

View file

@ -269,8 +269,7 @@ RCS_ID("$Id$")
default:
{
*actionClassNamePtr=[path objectAtIndex:0];
*actionNamePtr=[NSString stringWithFormat:@"%@",
[path objectAtIndex:1]];
*actionNamePtr=NSStringWithObject([path objectAtIndex:1]);
NSDebugMLog(@"*actionClassNamePtr=%@",*actionClassNamePtr);
NSDebugMLog(@"*actionNamePtr=%@",*actionNamePtr);
if ([*actionNamePtr isEqual:*actionClassNamePtr])

View file

@ -257,6 +257,9 @@ objectForReference:(NSString*)keyPath
//====================================================================
@implementation GSWBundle (GSWBundleA)
// returned relativePath won't have "/" prefix
-(id)lockedResourceNamed:(NSString*)aName
ofType:(NSString*)aType
withLanguages:(NSArray*)someLanguages
@ -281,24 +284,24 @@ objectForReference:(NSString*)keyPath
fileManager=[NSFileManager defaultManager];
NSAssert(fileManager,@"No fileManager");
fileName=[NSString stringWithFormat:@"%@.%@",aName,aType];
fileName=[aName stringByAppendingPathExtension:aType];
NSDebugMLLog(@"bundles",@"fileName=%@",fileName);
for(languageIndex=0;!resource && !path && languageIndex<=languagesNb;languageIndex++)
{
language=nil;
if (languageIndex==languagesNb)
relativePath=[@"/" stringByAppendingString:fileName];
relativePath=fileName;
else
{
language=[someLanguages objectAtIndex:languageIndex];
relativePath=[NSString stringWithFormat:@"/%@.%@/%@",
language,
GSLanguageSuffix,
fileName];
// format like: language.languageSuffix/fileName
relativePath=[language stringByAppendingPathExtension:GSLanguageSuffix];
relativePath=[relativePath stringByAppendingPathComponent:fileName];
};
NSDebugMLLog(@"bundles",@"language=%@",language);
NSDebugMLLog(@"bundles",@"relativePath=%@",relativePath);
absolutePath=[_path stringByAppendingString:relativePath];
absolutePath=[_path stringByAppendingPathComponent:relativePath];
NSDebugMLLog(@"bundles",@"absolutePath=%@",absolutePath);
if ([[GSWApplication application] isCachingEnabled])
resource=[aCache objectForKey:relativePath];
@ -322,12 +325,15 @@ objectForReference:(NSString*)keyPath
absolutePath=nil;
};
};
};
};
if (aRelativePath)
*aRelativePath=relativePath;
*aRelativePath=(([relativePath length]>0) ? relativePath : nil);
if (anAbsolutePath)
*anAbsolutePath=absolutePath;
*anAbsolutePath=(([absolutePath length]>0) ? absolutePath : nil);
LOGObjectFnStop();
return resource;
};
@end
@ -579,6 +585,10 @@ objectForReference:(NSString*)keyPath
usingCache:_templateCache
relativePath:&relativeTemplatePath
absolutePath:&absoluteTemplatePath];
NSDebugMLLog(@"bundles",@"relativeTemplatePath=%@",relativeTemplatePath);
NSDebugMLLog(@"bundles",@"absoluteTemplatePath=%@",absoluteTemplatePath);
if (!template)
{
if (!relativeTemplatePath)
@ -848,7 +858,10 @@ objectForReference:(NSString*)keyPath
NSString* relativePath=nil;
NSString* absolutePath=nil;
NSString* baseURL=nil;
LOGObjectFnStart();
// baseURL have / prefix, relativePath don't
baseURL=[self lockedResourceNamed:aName
ofType:aType
withLanguages:someLanguages
@ -859,11 +872,11 @@ objectForReference:(NSString*)keyPath
{
if (relativePath)
{
baseURL=relativePath;
baseURL=[relativePath stringByAppendingString:@"/"];
if ([[GSWApplication application] isCachingEnabled])
{
[_pathCache setObject:baseURL
forKey:relativePath];
forKey:relativePath];
};
};
};

View file

@ -1,6 +1,6 @@
/** GSWContext.h - <title>GSWeb: Class GSWContext</title>
Copyright (C) 1999-2004 Free Software Foundation, Inc.
Copyright (C) 1999-2005 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
@ -44,6 +44,7 @@ typedef struct _GSWContextIMPs
IMP _elementIDIMP;
IMP _componentIMP;
IMP _senderIDIMP;
IMP _contextAndElementIDIMP;
GSWIMP_BOOL _isParentSenderIDSearchOverIMP;
GSWIMP_BOOL _isSenderIDSearchOverIMP;
} GSWContextIMPs;
@ -60,6 +61,7 @@ GSWEB_EXPORT void GSWContext_deleteLastElementIDComponent(GSWContext* aContext);
GSWEB_EXPORT NSString* GSWContext_elementID(GSWContext* aContext);
GSWEB_EXPORT GSWComponent* GSWContext_component(GSWContext* aContext);
GSWEB_EXPORT NSString* GSWContext_senderID(GSWContext* aContext);
GSWEB_EXPORT NSString* GSWContext_contextAndElementID(GSWContext* aContext);
GSWEB_EXPORT BOOL GSWContext_isParentSenderIDSearchOver(GSWContext* aContext);
GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext);
@ -100,6 +102,7 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext);
NSMutableDictionary* _userInfo;
NSArray* _languages;
BOOL _isRefusingThisRequest;
BOOL _isSessionDisabled;
// IMPs for elementID manipulations
// As there's not many GSWContext objects, using some extra memory is not a problem
@ -127,6 +130,13 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext);
-(GSWSession*)_session;
-(GSWSession*)session;
-(BOOL)hasSession;
/** return YES is session creation|restoration is disabled **/
-(BOOL)isSessionDisabled;
/** pass YES as argument to disable session creation|restoration **/
-(void)setIsSessionDisabled:(BOOL)yn;
-(NSString*)senderID;
-(NSString*)contextID;
-(id)initWithRequest:(GSWRequest*)aRequest;

View file

@ -33,12 +33,14 @@
RCS_ID("$Id$")
#include "GSWeb.h"
#include "GSWPrivate.h"
static int dontTraceComponentActionURL=0;
static SEL componentSEL=NULL;
static SEL elementIDSEL=NULL;
static SEL senderIDSEL=NULL;
static SEL contextAndElementIDSEL=NULL;
static SEL isParentSenderIDSearchOverSEL=NULL;
static SEL isSenderIDSearchOverSEL=NULL;
@ -84,6 +86,9 @@ void GetGSWContextIMPs(GSWContextIMPs* impsPtr,GSWContext* context)
impsPtr->_senderIDIMP =
[context methodForSelector:senderIDSEL];
impsPtr->_contextAndElementIDIMP =
[context methodForSelector:contextAndElementIDSEL];
impsPtr->_isParentSenderIDSearchOverIMP =
(GSWIMP_BOOL)[context methodForSelector:isParentSenderIDSearchOverSEL];
@ -155,6 +160,16 @@ NSString* GSWContext_senderID(GSWContext* aContext)
return nil;
};
//--------------------------------------------------------------------
NSString* GSWContext_contextAndElementID(GSWContext* aContext)
{
if (aContext)
return (*(aContext->_selfIMPs._contextAndElementIDIMP))
(aContext,contextAndElementIDSEL);
else
return nil;
};
//--------------------------------------------------------------------
GSWComponent* GSWContext_component(GSWContext* aContext)
{
@ -196,6 +211,7 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext)
componentSEL=@selector(component);
elementIDSEL=@selector(elementID);
senderIDSEL=@selector(senderID);
contextAndElementIDSEL=@selector(contextAndElementID);
isParentSenderIDSearchOverSEL=@selector(isParentSenderIDSearchOver);
isSenderIDSearchOverSEL=@selector(isSenderIDSearchOver);
[self setStandardClass:[GSWContext class]];
@ -236,6 +252,9 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext)
standardContextIMPs._senderIDIMP =
[self instanceMethodForSelector:senderIDSEL];
standardContextIMPs._contextAndElementIDIMP =
[self instanceMethodForSelector:contextAndElementIDSEL];
standardContextIMPs._componentIMP =
[self instanceMethodForSelector:componentSEL];
@ -378,6 +397,7 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext)
clone->_actionInvoked=_actionInvoked;
clone->_formSubmitted=_formSubmitted;
clone->_isMultipleSubmitForm=_isMultipleSubmitForm;
clone->_isSessionDisabled=_isSessionDisabled;
};
return clone;
};
@ -389,7 +409,7 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext)
NSString* desc=nil;
dontTraceComponentActionURL++;
desc= [NSString stringWithFormat:
@"%s: %p contextID=%@ senderID=%@ elementID=%@ session=%p request=%p response=%p pageElement=%p pageComponent=%p currentComponent=%p url=%@ urlApplicationNumber=%d isClientComponentRequest=%s distributionEnabled=%s pageChanged=%s pageReplaced=%s",
@"%s: %p contextID=%@ senderID=%@ elementID=%@ session=%p request=%p response=%p pageElement=%p pageComponent=%p currentComponent=%p url=%@ urlApplicationNumber=%d isClientComponentRequest=%s distributionEnabled=%s isSessionDisabled=%s pageChanged=%s pageReplaced=%s",
object_get_class_name(self),
(void*)self,
[self contextID],
@ -405,6 +425,7 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext)
_urlApplicationNumber,
_isClientComponentRequest ? "YES" : "NO",
_distributionEnabled ? "YES" : "NO",
_isSessionDisabled ? "YES" : "NO",
_pageChanged ? "YES" : "NO",
_pageReplaced ? "YES" : "NO"];
dontTraceComponentActionURL--;
@ -475,9 +496,34 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext)
// returns contextID.ElementID
-(NSString*)contextAndElementID
{
return [NSString stringWithFormat:@"%u.%@",
_contextID,
[_elementID elementIDString]];
static NSString* preBuiltNumPlusDot[] = {
@"0.", @"1.", @"2.", @"3.", @"4.", @"5.", @"6.", @"7.", @"8.", @"9.",
@"10.", @"11.", @"12.", @"13.", @"14.", @"15.", @"16.", @"17.", @"18.", @"19.",
@"20.", @"21.", @"22.", @"23.", @"24.", @"25.", @"26.", @"27.", @"28.", @"29.",
@"30.", @"31.", @"32.", @"33.", @"34.", @"35.", @"36.", @"37.", @"38.", @"39.",
@"40.", @"41.", @"42.", @"43.", @"44.", @"45.", @"46.", @"47.", @"48.", @"49.",
@"50.", @"51.", @"52.", @"53.", @"54.", @"55.", @"56.", @"57.", @"58.", @"59.",
@"60.", @"61.", @"62.", @"63.", @"64.", @"65.", @"66.", @"67.", @"68.", @"69." };
static int preBuiltNumPlusDotCount = sizeof(preBuiltNumPlusDot)/sizeof(NSString*);
if (_contextID>=0 && _contextID<preBuiltNumPlusDotCount)
{
if (_elementID)
return [preBuiltNumPlusDot[_contextID] stringByAppendingString:
(*_elementIDIMPs._elementIDStringIMP)(_elementID,elementIDStringSEL)];
else
return preBuiltNumPlusDot[_contextID];
}
else
{
if (_elementID)
return [NSString stringWithFormat:@"%u.%@",
_contextID,
(*_elementIDIMPs._elementIDStringIMP)(_elementID,elementIDStringSEL)];
else
return [NSString stringWithFormat:@"%u.%@",
_contextID,
GSWContext_elementID(self)];
};
};
//--------------------------------------------------------------------
@ -489,11 +535,10 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext)
//--------------------------------------------------------------------
-(NSString*)contextID
{
//OK
if (_contextID==(unsigned int)-1)
return nil;
else
return [NSString stringWithFormat:@"%u",_contextID];
return GSWIntToNSString((int)_contextID);
};
//--------------------------------------------------------------------
@ -523,31 +568,63 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext)
return (_session!=nil);
};
//--------------------------------------------------------------------
/** return YES is session creation|restoration is disabled **/
-(BOOL)isSessionDisabled
{
return _isSessionDisabled;
}
//--------------------------------------------------------------------
/** pass YES as argument to disable session creation|restoration **/
-(void)setIsSessionDisabled:(BOOL)yn
{
LOGObjectFnStart();
_isSessionDisabled=yn;
NSDebugMLLog(@"sessions",@"_isSessionDisabled=%d",_isSessionDisabled);
LOGObjectFnStop();
}
//--------------------------------------------------------------------
-(GSWSession*)_session
{
return _session;
if ([self isSessionDisabled])
return nil;
else
return _session;
};
//--------------------------------------------------------------------
-(GSWSession*)session
{
GSWSession* session=nil;
LOGObjectFnStart();
if (!_session)
if (![self isSessionDisabled])
{
NSDebugMLLog(@"sessions",@"_requestSessionID=%@",_requestSessionID);
if (_requestSessionID)
[GSWApp restoreSessionWithID:_requestSessionID
inContext:self];//Application call context _setSession
};
if (!_session)
[GSWApp _initializeSessionInContext:self]; //Application call context _setSession
if (!_session)
{
NSString* requestSessionID=[self _requestSessionID];
NSDebugMLLog(@"sessions",@"requestSessionID=%@",requestSessionID);
if (requestSessionID)
[GSWApp restoreSessionWithID:requestSessionID
inContext:self];//Application call context _setSession
};
if (!_session)
[GSWApp _initializeSessionInContext:self]; //Application call context _setSession
NSAssert(_session,@"Unable to create new session");
NSAssert(_session,@"Unable to create new session");
session=_session;
};
NSDebugMLLog(@"sessions",@"session=%p",session);
LOGObjectFnStop();
return _session;
return session;
};
//--------------------------------------------------------------------
@ -643,7 +720,7 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext)
url=[self directActionURLForActionNamed:actionName
urlPrefix:urlPrefix
queryDictionary:queryDictionary
isSecure:NO];
isSecure:[[self request]isSecure]];
LOGObjectFnStop();
@ -681,7 +758,7 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext)
urlPrefix:urlPrefix
queryDictionary:queryDictionary
pathQueryDictionary:pathQueryDictionary
isSecure:NO];
isSecure:[[self request]isSecure]];
LOGObjectFnStop();
@ -792,7 +869,7 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext)
LOGObjectFnStartCond(dontTraceComponentActionURL==0);
url=[self componentActionURLIsSecure:NO];
url=[self componentActionURLIsSecure:[[self request]isSecure]];
LOGObjectFnStopCond(dontTraceComponentActionURL==0);
@ -859,19 +936,28 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext)
requestHandlerKey=componentRequestHandlerKey;
storesIDsInURLs=[session storesIDsInURLs];
NSDebugMLogCond(dontTraceComponentActionURL==0,@"storesIDsInURLs=%s",(storesIDsInURLs ? "YES" : "NO"));
if (storesIDsInURLs)
{
NSString* sessionID=[_session sessionID];
NSDebugMLogCond(dontTraceComponentActionURL==0,@"sessionID=%@",sessionID);
requestHandlerPath=[NSString stringWithFormat:@"%@/%u.%@",
sessionID,
_contextID,
elementID];
// requestHandlerPath as sessionID/_contextID.elementID
if (sessionID)
{
requestHandlerPath=[[sessionID stringByAppendingString:@"/"]
stringByAppendingString:GSWContext_contextAndElementID(self)];
}
else
{
requestHandlerPath=[@"/" stringByAppendingString:GSWContext_contextAndElementID(self)];
};
}
else
requestHandlerPath=[NSString stringWithFormat:@"/%u.%@", //??
_contextID,
elementID];
{
// requestHandlerPath as /_contextID.elementID
requestHandlerPath=[@"/" stringByAppendingString:GSWContext_contextAndElementID(self)];
};
NSDebugMLogCond(dontTraceComponentActionURL==0,@"requestHandlerPath=%@",requestHandlerPath);
url=[self urlWithRequestHandlerKey:requestHandlerKey
path:requestHandlerPath
@ -957,7 +1043,7 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext)
requestHandlerKey:requestHandlerKey
path:requestHandlerPath
queryString:queryString
isSecure:NO];
isSecure:[[self request]isSecure]];
LOGObjectFnStopCond(dontTraceComponentActionURL==0);
return url;
@ -1005,7 +1091,7 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext)
requestHandlerKey:requestHandlerKey
path:requestHandlerPath
queryString:queryString
isSecure:NO];
isSecure:[[self request]isSecure]];
};
//--------------------------------------------------------------------
@ -1310,7 +1396,7 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext)
urlPrefix:urlPrefix
queryDictionary:dict
pathQueryDictionary:pathQueryDictionary
isSecure:NO
isSecure:[[self request]isSecure]
url:anURL];
LOGObjectFnStop();
@ -1395,10 +1481,11 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext)
isSecure:(BOOL)isSecure
url:(id)anURL
{
NSString* queryString=nil;
NSMutableString* queryString=nil;
NSEnumerator* enumerator =nil;
id key=nil;
NSString* path=nil;
IMP queryString_appendStringIMP=NULL;
LOGObjectFnStart();
@ -1415,15 +1502,26 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext)
// _url=[[_url copy] autorelease];
//TODOV
enumerator = [dict keyEnumerator];
// Build queryString as key=value[&key=value]..
while ((key = [enumerator nextObject]))
{
if (!queryString)
queryString=[[NSString new] autorelease];
queryString=(NSMutableString*)[NSMutableString string];
else
queryString=[queryString stringByAppendingString:@"&"];
queryString=[queryString stringByAppendingFormat:@"%@=%@",
key,
[dict objectForKey:key]];
{
GSWeb_appendStringWithImpPtr(queryString,
&queryString_appendStringIMP,
@"&");
}
GSWeb_appendStringWithImpPtr(queryString,
&queryString_appendStringIMP,
NSStringWithObject(key));
GSWeb_appendStringWithImpPtr(queryString,
&queryString_appendStringIMP,
@"=");
GSWeb_appendStringWithImpPtr(queryString,
&queryString_appendStringIMP,
NSStringWithObject([dict objectForKey:key]));
};
/*
[anURL setURLRequestHandlerKey:GSWDirectActionRequestHandlerKey[GSWebNamingConv]];
@ -1437,14 +1535,17 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext)
isSecure:isSecure
port:0];
*/
path=actionName;
if ([pathQueryDictionary count]>0)
{
IMP tmpPath_appendStringIMP=NULL;
NSMutableString* tmpPath=(NSMutableString*)[NSMutableString stringWithString:actionName];
// We sort keys so URL are always the same for same parameters
NSArray* keys=[[pathQueryDictionary allKeys]sortedArrayUsingSelector:@selector(compare:)];
int count=[keys count];
int i=0;
NSDebugMLLog(@"gswdync",@"pathQueryDictionary=%@",pathQueryDictionary);
// append each key/value pair as /key=value
for(i=0;i<count;i++)
{
id key = [keys objectAtIndex:i];
@ -1453,11 +1554,19 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext)
NSDebugMLLog(@"gswdync",@"value=%@",value);
if (!value)
value=[NSString string];
path=[path stringByAppendingFormat:@"/%@=%@",
key,
value];
GSWeb_appendStringWithImpPtr(tmpPath,&tmpPath_appendStringIMP,
@"/");
GSWeb_appendStringWithImpPtr(tmpPath,&tmpPath_appendStringIMP,
NSStringWithObject(key));
GSWeb_appendStringWithImpPtr(tmpPath,&tmpPath_appendStringIMP,
@"=");
GSWeb_appendStringWithImpPtr(tmpPath,&tmpPath_appendStringIMP,
NSStringWithObject(value));
};
};
path=tmpPath;
}
else
path=actionName;
if (urlPrefix)
anURL=[self urlWithURLPrefix:urlPrefix
@ -1508,7 +1617,7 @@ If none, try request languages
LOGObjectFnStart();
languages=[_session languages];
languages=[[self _session] languages];
NSDebugMLLog(@"GSWContext",@"_session %p languages=%@",_session,languages);
if ([languages count]==0)
@ -1668,18 +1777,25 @@ If none, try request languages
BOOL storesIDsInURLs=NO;
BOOL isDistributionEnabled=NO;
NSString* sessionID=nil;
storesIDsInURLs=[_session storesIDsInURLs];
isDistributionEnabled=[_session isDistributionEnabled];
NSDebugMLLog(@"GSWContext",@"storesIDsInURLs=%d",storesIDsInURLs);
NSDebugMLLog(@"GSWContext",@"isDistributionEnabled=%d",isDistributionEnabled);
NSDebugMLLog(@"GSWContext",@"_session=%p",_session);
NSDebugMLLog(@"GSWContext",@"_request=%p",_request);
GSWSession* session=nil;
if (![self isSessionDisabled])
{
session=[self _session];
storesIDsInURLs=[session storesIDsInURLs];
isDistributionEnabled=[session isDistributionEnabled];
NSDebugMLLog(@"GSWContext",@"storesIDsInURLs=%d",storesIDsInURLs);
NSDebugMLLog(@"GSWContext",@"isDistributionEnabled=%d",isDistributionEnabled);
NSDebugMLLog(@"GSWContext",@"_session=%p",_session);
NSDebugMLLog(@"GSWContext",@"_request=%p",_request);
sessionID=[_request sessionID];
};
instance=[_request applicationNumber];
sessionID=[_request sessionID];
NSDebugMLLog(@"GSWContext",@"instance=%d",instance);
NSDebugMLLog(@"GSWContext",@"sessionID=%@",sessionID);
@ -1688,7 +1804,7 @@ If none, try request languages
// if we don't store IDs in URLs and distribution is enabled
// or if we don't have session nor session id
if ((isDistributionEnabled && !storesIDsInURLs)
|| (!_session && !sessionID))
|| (!session && !sessionID))
instance=-1;
};
@ -1710,7 +1826,10 @@ If none, try request languages
//--------------------------------------------------------------------
-(GSWSession*)existingSession
{
return _session;
if ([self isSessionDisabled])
return nil;
else
return _session;
};
//--------------------------------------------------------------------
@ -1974,13 +2093,13 @@ If none, try request languages
NSDebugMLLog(@"low",@"[request urlProtocolHorstPort]=%@",[_request urlProtocolHostPort]);
NSDebugMLLog(@"low",@"[request adaptorPrefix]=%@",[_request adaptorPrefix]);
NSDebugMLLog(@"low",@"[request applicationName]=%@",[_request applicationName]);
NSDebugMLLog(@"low",@"[session sessionID]=%@",[_session sessionID]);
NSDebugMLLog(@"low",@"[session sessionID]=%@",[[self _session] sessionID]);
return [NSString stringWithFormat:@"%@%@/%@.%@/%@",
[_request urlProtocolHostPort],
[_request adaptorPrefix],
[_request applicationName],
GSWApplicationSuffix[GSWebNamingConv],
[_session sessionID]];
[[self _session] sessionID]];
};

View file

@ -37,7 +37,7 @@
If *impPtr is NULL, the method assign it **/
static inline void GSWeb_appendStringWithImpPtr(NSMutableString* object,IMP* impPtr,NSString* string)
{
if (object)
if (object && string)
{
if (!*impPtr)
*impPtr=[object methodForSelector:@selector(appendString:)];