2003-04-09 Manuel Guesdon <mguesdon@orange-concept.com>

* GSWeb.framework/GSWSessionTimeOut.m:
		o fix in -description
	* GSWeb.framework/GSWApplication.m:
		o build currentRunLop before calling -run
		o log allFrameworks when a component is not found
	* GSWeb.framework/GSWHyperlink.m:
		o better handling of isSecure (regarding current request secure state)
	* GSWExtensions.framework/GSWSessionRestorationErrorPage.gswd:
		o use "" pageName so application may choose the main page
	* GSWExtensions.framework/GSWPageRestorationErrorPage.gswc/GSWPageRestorationErrorPage.gswd:
		o use "" pageName so application may choose the main page
	* GSWeb.framework/GSWConstants.m/.h:
		o added GSWHTTPHeader_Protocol, GSWHTTPHeader_ProtocolNum,
			GSWHTTPHeader_RequestScheme
	* GSWeb.framework/GSWContext.m/.h:
		o fix in -_synchronizeForDistribution
		o try to avoid complete URL when we can use relative one
	* GSWeb.framework/GSWRequest.m:
		o fix to retrieve protocol & port from adaptor headers
	* GSWeb.framework/GSWSession.m:
		o fix in -appendCookieToResponse:
	* GSAdaptors/Apache/mod_gsweb.c:
		o fix for server port header


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@16400 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Manuel Guesdon 2003-04-09 12:03:17 +00:00
parent 0fdce5c726
commit 5c4755be70
13 changed files with 215 additions and 58 deletions

View file

@ -1,3 +1,28 @@
2003-04-09 Manuel Guesdon <mguesdon@orange-concept.com>
* GSWeb.framework/GSWSessionTimeOut.m:
o fix in -description
* GSWeb.framework/GSWApplication.m:
o build currentRunLop before calling -run
o log allFrameworks when a component is not found
* GSWeb.framework/GSWHyperlink.m:
o better handling of isSecure (regarding current request secure state)
* GSWExtensions.framework/GSWSessionRestorationErrorPage.gswd:
o use "" pageName so application may choose the main page
* GSWExtensions.framework/GSWPageRestorationErrorPage.gswc/GSWPageRestorationErrorPage.gswd:
o use "" pageName so application may choose the main page
* GSWeb.framework/GSWConstants.m/.h:
o added GSWHTTPHeader_Protocol, GSWHTTPHeader_ProtocolNum,
GSWHTTPHeader_RequestScheme
* GSWeb.framework/GSWContext.m/.h:
o fix in -_synchronizeForDistribution
o try to avoid complete URL when we can use relative one
* GSWeb.framework/GSWRequest.m:
o fix to retrieve protocol & port from adaptor headers
* GSWeb.framework/GSWSession.m:
o fix in -appendCookieToResponse:
* GSAdaptors/Apache/mod_gsweb.c:
o fix for server port header
2003-04-05 Manuel Guesdon <mguesdon@orange-concept.com>
* GSWAdaptors/common/config.h:
o change minor version

View file

@ -362,9 +362,20 @@ copyHeaders(request_rec *p_pRequestRec,
g_szServerInfo_ServerName,
pServerRec->server_hostname);
pszPort = APR_PSPRINTF(p_pRequestRec->pool,
"%u",
pServerRec->port);
{
unsigned int serverPort=(unsigned)ap_get_server_port(p_pRequestRec);
if (serverPort==0)
{
if (p_pRequestRec->parsed_uri.port_str && p_pRequestRec->parsed_uri.port!=0)
serverPort=(unsigned)p_pRequestRec->parsed_uri.port;
else
serverPort=(unsigned)pServerRec->port;
};
pszPort = APR_PSPRINTF(p_pRequestRec->pool,
"%u",
(unsigned int)serverPort);
};
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
g_szServerInfo_ServerPort,
pszPort);

View file

@ -12,7 +12,7 @@ ApplicationNameString: GSWString
ReenterHyperlink: GSWHyperlink
{
pageName = "Main";
pageName = "";
target = "_top";
};

View file

@ -12,6 +12,6 @@ ApplicationNameString: GSWString
ReenterHyperlink: GSWHyperlink
{
pageName = "Main";
pageName = "";
target = "_top";
}

View file

@ -449,8 +449,8 @@ int GSWApplicationMainReal(NSString* applicationClassName,
};
};
};
NSDebugFLLog(@"bundles",@"[NSBundle allBundles]=%@",[NSBundle allBundles]);
NSDebugFLLog(@"bundles",@"[NSBundle allFrameworks]=%@",[NSBundle allFrameworks]);
NSDebugFLLog(@"bundles",@"[NSBundle allBundles] pathes=%@",[[NSBundle allBundles] valueForKey:@"resourcePath"]);
NSDebugFLLog(@"bundles",@"[NSBundle allFrameworks] pathes=%@",[[NSBundle allFrameworks] valueForKey:@"resourcePath"]);
};
if (result>=0)
{
@ -480,7 +480,9 @@ int GSWApplicationMainReal(NSString* applicationClassName,
if (result>=0 && GSWApp)
{
[GSWApp _setPool:[NSAutoreleasePool new]];
[GSWApp run];
DESTROY(GSWApp);
};
GSWLogMemCF("Destroy NSAutoreleasePool: %p",appAutoreleasePool);
@ -547,6 +549,13 @@ int GSWApplicationMain(NSString* applicationClassName,
// context=nil;//deprecated
_selfLock=[NSRecursiveLock new];
_globalLock=[NSLock new];
NSDebugMLLog(@"application",@"GSCurrentThreadDictionary()=%@",GSCurrentThreadDictionary());
//Do it before run so application can addTimer,... in -run
NSDebugMLLog(@"application",@"[NSRunLoop currentRunLoop]=%@",[NSRunLoop currentRunLoop]);
ASSIGN(_currentRunLoop,[NSRunLoop currentRunLoop]);
_pageCacheSize=30;
_permanentPageCacheSize=30;
_pageRecreationEnabled=YES;
@ -1262,6 +1271,7 @@ selfLockn,
};
if (!componentDefinition)
{
NSLog(@"EXCEPTION: allFrameworks pathes=%@",[[NSBundle allFrameworks] valueForKey:@"resourcePath"]);
ExceptionRaise(GSWPageNotFoundException,
@"Unable to create component definition for %@ for languages: %@ (no componentDefinition).",
aName,
@ -1369,7 +1379,8 @@ selfLockn,
LOGObjectFnStart();
allFrameworks=[[NSBundle allFrameworks] mutableCopy];
[allFrameworks addObjectsFromArray:[NSBundle allBundles]];
// NSDebugMLLog(@"gswcomponents",@"_allFrameworks=%@",_allFrameworks);
//NSDebugMLLog(@"gswcomponents",@"allFrameworks=%@",allFrameworks);
//NSDebugFLLog(@"gswcomponents",@"allFrameworks pathes=%@",[allFrameworks valueForKey:@"resourcePath"]);
array=[self lockedInitComponentBearingFrameworksFromBundleArray:allFrameworks];
NSDebugMLLog(@"gswcomponents",@"array=%@",array);
[allFrameworks release];
@ -1391,12 +1402,13 @@ selfLockn,
for(i=0;i<[bundles count];i++)
{
bundle=[bundles objectAtIndex:i];
// NSDebugMLLog(@"gswcomponents",@"_bundle=%@",_bundle);
//NSDebugMLLog(@"gswcomponents",@"bundle=%@",bundle);
//NSDebugMLLog(@"gswcomponents",@"bundle resourcePath=%@",[bundle resourcePath]);
bundleInfo=[bundle infoDictionary];
// NSDebugMLLog(@"gswcomponents",@"_bundleInfo=%@",_bundleInfo);
//NSDebugMLLog(@"gswcomponents",@"bundleInfo=%@",bundleInfo);
hasGSWComponents=[bundleInfo objectForKey:@"HasGSWComponents"];
// NSDebugMLLog(@"gswcomponents",@"_hasGSWComponents=%@",_hasGSWComponents);
// NSDebugMLLog(@"gswcomponents",@"_hasGSWComponents class=%@",[_hasGSWComponents class]);
//NSDebugMLLog(@"gswcomponents",@"hasGSWComponents=%@",hasGSWComponents);
//NSDebugMLLog(@"gswcomponents",@"hasGSWComponents class=%@",[hasGSWComponents class]);
if (boolValueFor(hasGSWComponents))
{
[array addObject:bundle];
@ -2324,9 +2336,9 @@ selfLockn,
//call self _openInitialURL
NSDebugMLLog(@"application",@"GSCurrentThreadDictionary()=%@",GSCurrentThreadDictionary());
NSDebugMLLog(@"application",@"[NSRunLoop currentRunLoop]=%@",[NSRunLoop currentRunLoop]);
ASSIGN(_currentRunLoop,[NSRunLoop currentRunLoop]);
NSDebugMLLog(@"application",@"GSCurrentThreadDictionary()=%@",GSCurrentThreadDictionary());
[[NSRunLoop currentRunLoop] run];
NSAssert(_currentRunLoop,@"No runLoop");
[_currentRunLoop run];
NSDebugMLLog0(@"application",@"NSRunLoop end run");
[_adaptors makeObjectsPerformSelector:unregisterForEventsSEL];
@ -2339,7 +2351,7 @@ selfLockn,
-(NSRunLoop*)runLoop
{
return _currentRunLoop;//[NSRunLoop currentRunLoop];
return _currentRunLoop;
};
//--------------------------------------------------------------------

View file

@ -115,6 +115,10 @@ extern NSString* GSWHTTPHeader_AuthPass[2];
extern NSString* GSWHTTPHeader_AuthType[2];
extern NSString* GSWHTTPHeader_DocumentRoot[2];
extern NSString* GSWHTTPHeader_GatewayInterface[2];
extern NSString* GSWHTTPHeader_Protocol[2];
extern NSString* GSWHTTPHeader_ProtocolNum[2];
extern NSString* GSWHTTPHeader_RequestScheme[2];
extern NSString* GSWHTTPHeader_Method[2];
extern NSString* GSWHTTPHeader_MethodPost;
extern NSString* GSWHTTPHeader_MethodGet;

View file

@ -123,6 +123,9 @@ NSString* GSWHTTPHeader_AuthPass[2]={ @"x-gsweb-auth-pass", @"x-webobjects-auth-
NSString* GSWHTTPHeader_AuthType[2]={ @"x-gsweb-auth-type", @"x-webobjects-auth-type" };
NSString* GSWHTTPHeader_DocumentRoot[2]={ @"x-gsweb-documentroot", @"x-webobjects-documentroot" };
NSString* GSWHTTPHeader_GatewayInterface[2]={ @"x-gsweb-gateway-interface", @"x-webobjects-gateway-interface" };
NSString* GSWHTTPHeader_Protocol[2]={ @"x-gsweb-server-protocol", @"x-webobjects-server-protocol" };
NSString* GSWHTTPHeader_ProtocolNum[2]={ @"x-gsweb-server-protocol-num", @"x-webobjects-server-protocol-num" };
NSString* GSWHTTPHeader_RequestScheme[2]={ @"x-gsweb-request-scheme", @"x-webobjects-request-scheme" };
NSString* GSWHTTPHeader_MethodPost=@"POST";
NSString* GSWHTTPHeader_MethodGet=@"GET";

View file

@ -108,6 +108,11 @@
isSecure:(BOOL)isSecure;
-(GSWDynamicURLString*)componentActionURL;
-(GSWDynamicURLString*)componentActionURLIsSecure:(BOOL)isSecure;
-(GSWDynamicURLString*)urlWithRequestHandlerKey:(NSString*)requestHandlerKey
path:(NSString*)requestHandlerPath
queryString:(NSString*)queryString
isSecure:(BOOL)isSecure
port:(int)port;
-(GSWDynamicURLString*)urlWithRequestHandlerKey:(NSString*)requestHandlerKey
path:(NSString*)requestHandlerPath
queryString:(NSString*)queryString;

View file

@ -472,6 +472,40 @@ static int dontTraceComponentActionURL=0;
return url;
};
//--------------------------------------------------------------------
-(GSWDynamicURLString*)urlWithRequestHandlerKey:(NSString*)requestHandlerKey
path:(NSString*)requestHandlerPath
queryString:(NSString*)queryString
isSecure:(BOOL)isSecure
port:(int)port
{
//OK
GSWDynamicURLString* url=nil;
GSWRequest* request=[self request];
LOGObjectFnStartCond(dontTraceComponentActionURL==0);
NSDebugMLogCond(dontTraceComponentActionURL==0,
@"generateCompleteURLs=%s",
(_generateCompleteURLs ? "YES" : "NO"));
// Try to avoid complete URLs
if (_generateCompleteURLs
|| (isSecure!=[request isSecure])
|| (port!=0 && port!=[request urlPort]))
url=[self completeURLWithRequestHandlerKey:requestHandlerKey
path:requestHandlerPath
queryString:queryString
isSecure:isSecure
port:port];
else
url=[request _urlWithRequestHandlerKey:requestHandlerKey
path:requestHandlerPath
queryString:queryString];
NSDebugMLogCond(dontTraceComponentActionURL==0,
@"url=%@",url);
LOGObjectFnStopCond(dontTraceComponentActionURL==0);
return url;
};
//--------------------------------------------------------------------
-(GSWDynamicURLString*)urlWithRequestHandlerKey:(NSString*)requestHandlerKey
path:(NSString*)requestHandlerPath
@ -539,7 +573,7 @@ static int dontTraceComponentActionURL=0;
[url setURLPort:port];
NSDebugMLLog(@"low",@"url=%@",url);
host=[request urlHost];
NSAssert(host,@"No host !");
NSAssert1(host,@"No host in request %@",request);
NSDebugMLLog(@"low",@"host=%@",host);
[url setURLHost:host];
NSDebugMLLog(@"low",@"url=%@",url);
@ -688,7 +722,14 @@ static int dontTraceComponentActionURL=0;
[anURL setURLRequestHandlerPath:actionName];
[anURL setURLQueryString:queryString];
*/
anURL=[self completeURLWithRequestHandlerKey:GSWDirectActionRequestHandlerKey[GSWebNamingConv]
/* anURL=[self completeURLWithRequestHandlerKey:GSWDirectActionRequestHandlerKey[GSWebNamingConv]
path:actionName
queryString:queryString
isSecure:isSecure
port:0];
*/
anURL=[self urlWithRequestHandlerKey:GSWDirectActionRequestHandlerKey[GSWebNamingConv]
path:actionName
queryString:queryString
isSecure:isSecure
@ -837,16 +878,26 @@ static int dontTraceComponentActionURL=0;
//--------------------------------------------------------------------
-(void)_synchronizeForDistribution
{
//OK
int instance=-1;
NSString* sessionID=nil;
BOOL storesIDsInURLs=NO;
BOOL isDistributionEnabled=NO;
LOGObjectFnStart();
if (_session)
storesIDsInURLs=[_session storesIDsInURLs];
isDistributionEnabled=[_session isDistributionEnabled];
if (_request)
{
//call session storesIDsInURLs [ret 1]
//call session isDistributionEnabled [ret 0]
[_url setURLApplicationNumber:[_request applicationNumber]];//OK
}
instance=[_request applicationNumber];
sessionID=[_request sessionID];
};
if (instance<-1
|| (storesIDsInURLs && ! isDistributionEnabled)
|| (sessionID && instance>=0))
instance=[_request applicationNumber];
else
[_url setURLApplicationNumber:-1];//OK
instance=-1;
_urlApplicationNumber = instance;
[_url setURLApplicationNumber:instance];
LOGObjectFnStop();
};

View file

@ -312,10 +312,17 @@ RCS_ID("$Id$")
//OK
NSString* anUrl=nil;
BOOL completeUrlsPreviousState=NO;
BOOL isSecure=[self evaluateCondition:_secure
inContext:context];
BOOL isSecure=NO;
BOOL requestIsSecure=[[context request]isSecure];
if (_secure)
isSecure=[self evaluateCondition:_secure
inContext:context];
else
isSecure=requestIsSecure;
// Force complete URLs
if (isSecure)
if (isSecure!=requestIsSecure)
completeUrlsPreviousState=[context _generateCompleteURLs];
anUrl=(NSString*)[context componentActionURLIsSecure:isSecure];
NSDebugMLLog(@"gswdync",@"anUrl=%@",anUrl);
@ -324,7 +331,7 @@ RCS_ID("$Id$")
inContext:context];
[self _appendFragmentToResponse:response
inContext:context];
if (isSecure && !completeUrlsPreviousState)
if (isSecure!=requestIsSecure && !completeUrlsPreviousState)
[context _generateRelativeURLs];
}
else if (!WOStrictFlag && (_filename || _data))
@ -478,6 +485,7 @@ RCS_ID("$Id$")
NSString* anUrl=nil;
BOOL completeUrlsPreviousState=NO;
BOOL isSecure=NO;
BOOL requestIsSecure=NO;
LOGObjectFnStart();
actionString=[self computeActionStringInContext:context];
@ -486,10 +494,15 @@ RCS_ID("$Id$")
queryDictionary=[self computeQueryDictionaryInContext:context];
NSDebugMLLog(@"gswdync",@"queryDictionary=%@",queryDictionary);
isSecure=[self evaluateCondition:_secure
inContext:context];
// Force complete URLs
if (isSecure)
requestIsSecure=[[context request]isSecure];
if (_secure)
isSecure=[self evaluateCondition:_secure
inContext:context];
else
isSecure=requestIsSecure;
// Force complete URLs is secure mode is not the same
if (isSecure!=requestIsSecure)
completeUrlsPreviousState=[context _generateCompleteURLs];
anUrl=(NSString*)[context directActionURLForActionNamed:actionString
@ -497,7 +510,7 @@ RCS_ID("$Id$")
isSecure:isSecure];
NSDebugMLLog(@"gswdync",@"anUrl=%@",anUrl);
if (isSecure && !completeUrlsPreviousState)
if (isSecure!=requestIsSecure && !completeUrlsPreviousState)
[context _generateRelativeURLs];
[response appendContentString:anUrl];

View file

@ -56,6 +56,7 @@ RCS_ID("$Id$")
NSDebugMLLog(@"requests",@"method=%@",_method);
ASSIGNCOPY(_httpVersion,aVersion);
ASSIGNCOPY(_headers,headers);
//NSLog(@"HEADERS=%@",_headers);
_defaultFormValueEncoding=NSISOLatin1StringEncoding;
_formValueEncoding=NSISOLatin1StringEncoding;
[self _initCookieDictionary];//NDFN
@ -231,10 +232,17 @@ RCS_ID("$Id$")
//NDFN
-(NSString*)urlProtocol
{
//TODO
NSString* urlProtocol=[_uri urlProtocol];
if (!urlProtocol)
urlProtocol=GSWProtocol_HTTP;
{
urlProtocol=[self headerForKey:GSWHTTPHeader_RequestScheme[GSWebNamingConv]];
if (!urlProtocol)
{
urlProtocol=[self headerForKey:GSWHTTPHeader_RequestScheme[GSWebNamingConvInversed]];
if (!urlProtocol)
urlProtocol=GSWProtocol_HTTP;
};
};
return urlProtocol;
};
@ -244,9 +252,11 @@ RCS_ID("$Id$")
{
NSString* urlHost=[_uri urlHost];
if (!urlHost)
urlHost=[self headerForKey:GSWHTTPHeader_ServerName[GSWebNamingConv]];
if (!urlHost)
urlHost=[self headerForKey:GSWHTTPHeader_ServerName[GSWebNamingConvInversed]];
{
urlHost=[self headerForKey:GSWHTTPHeader_ServerName[GSWebNamingConv]];
if (!urlHost)
urlHost=[self headerForKey:GSWHTTPHeader_ServerName[GSWebNamingConvInversed]];
};
return urlHost;
};
@ -256,9 +266,11 @@ RCS_ID("$Id$")
{
NSString* urlPortString=[_uri urlPortString];
if (!urlPortString)
urlPortString=[self headerForKey:GSWHTTPHeader_ServerPort[GSWebNamingConv]];
if (!urlPortString)
urlPortString=[self headerForKey:GSWHTTPHeader_ServerPort[GSWebNamingConvInversed]];
{
urlPortString=[self headerForKey:GSWHTTPHeader_ServerPort[GSWebNamingConv]];
if (!urlPortString)
urlPortString=[self headerForKey:GSWHTTPHeader_ServerPort[GSWebNamingConvInversed]];
};
return urlPortString;
};
@ -268,9 +280,11 @@ RCS_ID("$Id$")
{
int port=[_uri urlPort];
if (!port)
port=[[self headerForKey:GSWHTTPHeader_ServerPort[GSWebNamingConv]]intValue];
if (!port)
port=[[self headerForKey:GSWHTTPHeader_ServerPort[GSWebNamingConvInversed]]intValue];
{
port=[[self headerForKey:GSWHTTPHeader_ServerPort[GSWebNamingConv]]intValue];
if (!port)
port=[[self headerForKey:GSWHTTPHeader_ServerPort[GSWebNamingConvInversed]]intValue];
};
return port;
};
@ -285,7 +299,7 @@ RCS_ID("$Id$")
//NDFN
-(BOOL)isSecure
{
return [[self urlProtocol] isEqualToString:GSWProtocol_HTTPS];
return ([[self urlProtocol] caseInsensitiveCompare:GSWProtocol_HTTPS]==NSOrderedSame);
};
//--------------------------------------------------------------------

View file

@ -717,20 +717,22 @@ RCS_ID("$Id$")
{
NSString* domainForIDCookies=nil;
NSString* sessionID=nil;
NSDate* anExpireDate=nil;
LOGObjectFnStart();
domainForIDCookies=[self domainForIDCookies];
sessionID=[self sessionID];
anExpireDate=[NSDate date]; // Expire now
[aResponse addCookie:[GSWCookie cookieWithName:GSWKey_SessionID[GSWebNamingConv]
value:sessionID
path:domainForIDCookies
domain:nil
expires:[self expirationDateForIDCookies]
expires:anExpireDate
isSecure:NO]];
[aResponse addCookie:[GSWCookie cookieWithName:GSWKey_InstanceID[GSWebNamingConv]
value:@"-1" //TODO
value:@"-1"
path:domainForIDCookies
domain:nil
expires:[self expirationDateForIDCookies]
expires:anExpireDate
isSecure:NO]];
LOGObjectFnStop();
@ -744,22 +746,39 @@ RCS_ID("$Id$")
if ([self storesIDsInCookies])
{
//TODO VERIFY
NSString* domainForIDCookies=nil;
NSString* sessionID=nil;
domainForIDCookies=[self domainForIDCookies];
sessionID=[self sessionID];
NSString* domainForIDCookies=[self domainForIDCookies];
NSString* sessionID=[self sessionID];
int instance=-1;
NSDate* anExpireDate=[self expirationDateForIDCookies];
// SessionID cookie
[aResponse addCookie:[GSWCookie cookieWithName:GSWKey_SessionID[GSWebNamingConv]
value:sessionID
path:domainForIDCookies
domain:nil
expires:[self expirationDateForIDCookies]
expires:anExpireDate
isSecure:NO]];
// Instance Cookie
// No Instance if distribution enabled or this session is terminating
if ([self isDistributionEnabled] || [self isTerminating])
{
instance=-1;
anExpireDate=[NSDate date]; //expire now !
}
else
{
GSWRequest* request = [_currentContext request];
if (request)
instance=[request applicationNumber]; // use the request instance number
else
instance=-1;
};
[aResponse addCookie:[GSWCookie cookieWithName:GSWKey_InstanceID[GSWebNamingConv]
value:@"1" //TODO
value:[NSString stringWithFormat:@"%d",instance]
path:domainForIDCookies
domain:nil
expires:[self expirationDateForIDCookies]
expires:anExpireDate
isSecure:NO]];
};

View file

@ -80,7 +80,7 @@ RCS_ID("$Id$")
//--------------------------------------------------------------------
-(NSString*)description
{
return [NSString stringWithFormat:@"<%s %p - sessionID=%@ timeOutTime=%f lastAccessTime=%f timeOut=%ld",
return [NSString stringWithFormat:@"<%s %p - sessionID=%@ timeOutTime=%@ lastAccessTime=%@ timeOut=%ld",
object_get_class_name(self),
(void*)self,
_sessionID,