2003-01-19 Manuel Guesdon <mguesdon@orange-concept.com>

* GSWeb/GSWApplication.m
		o removed unused +initialize
	* GSWeb/GSWDefaultAdaptorThread.m:
		o more information on "bad request first line" exception
	* GSWeb/GSWHTMLDynamicElement.m
		o in -initWithName:attributeAssociations:contentElements:
			add "" to association values because XML parser romove them.
		o added -computeActionStringWithActionClassAssociation:
				directActionNameAssociation:inContext:
		o added -computeQueryDictionaryWithActionClassAssociation:
				directActionNameAssociation:queryDictionaryAssociation:
				otherQueryAssociations:inContext:
	* GSWeb/GSWResponse.m:
		o don't append debugcomment if !GSDebugSet(@"debugComments")
		o fixed bug in appendContentString: in NSAssert3 params
		o adedd -_appendTagAttribute:value:escapingHTMLAttributeValue:
		o added GSWResponse (GSWResponseRedirected)
	* GSWeb/GSWResponse.h:
		o added -forceFinalizeInContext
		o added GSWResponse (GSWResponseRedirected)
	* GSWeb/GSWTemplateParserXML.m:
		o only include comments if [GSWApplication includeCommentsInResponses]
	* GSWExtensions.framework/GSWLongResponsePage.m:
		o in -cancel call cancelPageForStatus: instead of cancelPage
		o declare private interface
	* GSWeb/GSWComponent.m:
		o don't output end of component commend if !DEBUG && !GSDebugSet(@"gswcomponents")
		o fixes in _generateResponseInContext:
	* GSWeb/GSWContext.[hm]:
		o added _userInfo to enable developper context specific
			temporary information storage
		o added -userInfo
		o added -_generateRelativeURLs
		o make -_generateCompleteURLs returning previous state.
		o added -directActionURLForActionNamed:queryDictionary:isSecure:
		o added -_directActionURLForActionNamed:queryDictionary:isSecure:url:
		o added -componentActionURLIsSecure:
		o modified -session
		o modified -_takeAwakeComponent: to not add already added component
		o implemented _takeAwakeComponentsFromArray;
		o fixed -_incrementContextID
		o added _session
		o fixes in -copyWithZone to keep mutable objects mutables.
		o added _requestContextID
		o added -_setRequestContextID: and -_requestContextID;
	* GSWeb/GSWHyperlink.[hm]:
		o added _secure
		o added binding validation tests
		o fixes in -appendToResponse:inContext:
		o handle correctly otherQueryAssociations (bindings starting with '?')
	* GSWeb/GSWConstants.[hm]:
		o added cidStore__Key for GSWHTMLURLValuedElement
		o added cidKey__Key for GSWHTMLURLValuedElement
	* GSWeb/GSWImage.[hm]:
		o added _width, _height
	* GSWeb/GSWHTMLURLValuedElement.[hm]
		o implemented -_appendCGIActionURLToResponse:inContext:
		o implemented -computeActionStringInContext:
		o implemented -computeQueryDictionaryInContext:
		o handle otherQueryAssociations (bindings starting with '?')
		o handle cidStore and cidKey
	* GSWeb/GSWRequest.[hm]:
		o added _context
		o changes for compilation warnings
		o added -sessionIDFromValuesOrCookieByLookingForCookieFirst:
		o added +_lookForIDsInCookiesFirst
		o rewrite form/uri/cookie values retrieving (for sessionID,...)
		o new use GSMimeParser for formData parsing
	* Doc/antlr.txt added
	* GSWeb/GSWPageDefParser.[hm] regenerated to handle (bindings starting with '?')
	* GSWeb/GSWPageDefParserTokenTypes.txt regenerated to handle (bindings starting with '?')
	* GSWeb/GSWPageDefParserTokenTypes.h regenerated to handle (bindings starting with '?')
	* GSWeb/GSWPageDefLexer.[hm]  regenerated to handle (bindings starting with '?')
	* GSWeb/GSWUtils.[hm]:
		o added -extractObjectsForKeysWithPrefix:removePrefix:
		o fixed bug in HexStringToData
		o fixed bug in NSDictionary +dictionaryWithArray:onSelector:withObject:
	* GSWeb/GSWForm.[hm]
		o handle otherQueryAssociations (bindings starting with '?')
		o implemented -computeQueryDictionaryInContext:
		o implemented/fixed -_appendHiddenFieldsToResponse:inContext:
		o implemented -_appendCGIActionToResponse:inContext:
		o fix -appendGSWebObjectsAssociationsToResponse:inContext: for directAction
		o added -computeActionStringInContext:
		o fixed -invokeActionForRequest:inContext: to invoke action when to element is invoked
	* GSWeb/GSWDirectAction.m:
		o fixed -_initializeRequestSessionIDInContext:
		o added -sessionIDForRequest:
	* GSWeb/NSString+HTML.[hm]:
		o added -dictionaryWithSep1:withSep2:withOptionUnescape:forceArray:
	* GSWeb/NSString+Trimming.m:
		o fix in +stringUniqueIdWithLength: initialize random generator
	* GSWeb/GSWSession.[hm]:
		o added createSessionID which create better sessionID
			(uniq in time and larger to give better security)
		o fixes in _saveCurrentPage
	* GSWeb/GSWBundle.m:
		o fix compiler warning


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@15630 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Manuel Guesdon 2003-01-19 15:33:07 +00:00
parent fd97c0fd04
commit e016ce3909
53 changed files with 2776 additions and 973 deletions

100
ChangeLog
View file

@ -1,3 +1,103 @@
2003-01-19 Manuel Guesdon <mguesdon@orange-concept.com>
* GSWeb/GSWApplication.m
o removed unused +initialize
* GSWeb/GSWDefaultAdaptorThread.m:
o more information on "bad request first line" exception
* GSWeb/GSWHTMLDynamicElement.m
o in -initWithName:attributeAssociations:contentElements:
add "" to association values because XML parser romove them.
o added -computeActionStringWithActionClassAssociation:
directActionNameAssociation:inContext:
o added -computeQueryDictionaryWithActionClassAssociation:
directActionNameAssociation:queryDictionaryAssociation:
otherQueryAssociations:inContext:
* GSWeb/GSWResponse.m:
o don't append debugcomment if !GSDebugSet(@"debugComments")
o fixed bug in appendContentString: in NSAssert3 params
o adedd -_appendTagAttribute:value:escapingHTMLAttributeValue:
o added GSWResponse (GSWResponseRedirected)
* GSWeb/GSWResponse.h:
o added -forceFinalizeInContext
o added GSWResponse (GSWResponseRedirected)
* GSWeb/GSWTemplateParserXML.m:
o only include comments if [GSWApplication includeCommentsInResponses]
* GSWExtensions.framework/GSWLongResponsePage.m:
o in -cancel call cancelPageForStatus: instead of cancelPage
o declare private interface
* GSWeb/GSWComponent.m:
o don't output end of component commend if !DEBUG && !GSDebugSet(@"gswcomponents")
o fixes in _generateResponseInContext:
* GSWeb/GSWContext.[hm]:
o added _userInfo to enable developper context specific
temporary information storage
o added -userInfo
o added -_generateRelativeURLs
o make -_generateCompleteURLs returning previous state.
o added -directActionURLForActionNamed:queryDictionary:isSecure:
o added -_directActionURLForActionNamed:queryDictionary:isSecure:url:
o added -componentActionURLIsSecure:
o modified -session
o modified -_takeAwakeComponent: to not add already added component
o implemented _takeAwakeComponentsFromArray;
o fixed -_incrementContextID
o added _session
o fixes in -copyWithZone to keep mutable objects mutables.
o added _requestContextID
o added -_setRequestContextID: and -_requestContextID;
* GSWeb/GSWHyperlink.[hm]:
o added _secure
o added binding validation tests
o fixes in -appendToResponse:inContext:
o handle correctly otherQueryAssociations (bindings starting with '?')
* GSWeb/GSWConstants.[hm]:
o added cidStore__Key for GSWHTMLURLValuedElement
o added cidKey__Key for GSWHTMLURLValuedElement
* GSWeb/GSWImage.[hm]:
o added _width, _height
* GSWeb/GSWHTMLURLValuedElement.[hm]
o implemented -_appendCGIActionURLToResponse:inContext:
o implemented -computeActionStringInContext:
o implemented -computeQueryDictionaryInContext:
o handle otherQueryAssociations (bindings starting with '?')
o handle cidStore and cidKey
* GSWeb/GSWRequest.[hm]:
o added _context
o changes for compilation warnings
o added -sessionIDFromValuesOrCookieByLookingForCookieFirst:
o added +_lookForIDsInCookiesFirst
o rewrite form/uri/cookie values retrieving (for sessionID,...)
o new use GSMimeParser for formData parsing
* Doc/antlr.txt added
* GSWeb/GSWPageDefParser.[hm] regenerated to handle (bindings starting with '?')
* GSWeb/GSWPageDefParserTokenTypes.txt regenerated to handle (bindings starting with '?')
* GSWeb/GSWPageDefParserTokenTypes.h regenerated to handle (bindings starting with '?')
* GSWeb/GSWPageDefLexer.[hm] regenerated to handle (bindings starting with '?')
* GSWeb/GSWUtils.[hm]:
o added -extractObjectsForKeysWithPrefix:removePrefix:
o fixed bug in HexStringToData
o fixed bug in NSDictionary +dictionaryWithArray:onSelector:withObject:
* GSWeb/GSWForm.[hm]
o handle otherQueryAssociations (bindings starting with '?')
o implemented -computeQueryDictionaryInContext:
o implemented/fixed -_appendHiddenFieldsToResponse:inContext:
o implemented -_appendCGIActionToResponse:inContext:
o fix -appendGSWebObjectsAssociationsToResponse:inContext: for directAction
o added -computeActionStringInContext:
o fixed -invokeActionForRequest:inContext: to invoke action when to element is invoked
* GSWeb/GSWDirectAction.m:
o fixed -_initializeRequestSessionIDInContext:
o added -sessionIDForRequest:
* GSWeb/NSString+HTML.[hm]:
o added -dictionaryWithSep1:withSep2:withOptionUnescape:forceArray:
* GSWeb/NSString+Trimming.m:
o fix in +stringUniqueIdWithLength: initialize random generator
* GSWeb/GSWSession.[hm]:
o added createSessionID which create better sessionID
(uniq in time and larger to give better security)
o fixes in _saveCurrentPage
* GSWeb/GSWBundle.m:
o fix compiler warning
2002-12-11 Manuel Guesdon <mguesdon@orange-concept.com>
* GSWeb/GSWAdaptors/common/GSWUtil.h
o changes to handle Apache 2.x

7
Doc/antlr.txt Normal file
View file

@ -0,0 +1,7 @@
To generate Parser classes:
export CPA="/usr/lib/kaffe:/usr/share/kaffe/Klasses.jar:/usr/share/kaffe/pjava.jar:/usr/share/kaffe/tools.jar:${JNDI_LIB}:${NETSCAPE_LIB}:./plugins:."
and in antlr directory:
java -classpath "$CPA" antlr.Tool /PathTo/PageDef.g

View file

@ -1,12 +1,13 @@
/** GSWLongResponsePage.m - <title>GSWeb: Class GSWLongResponsePage</title>
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Sep 2002
$Revision$
$Date$
$Id$
<abstract></abstract>
@ -29,11 +30,19 @@
</license>
**/
static char rcsId[] = "$Id$";
static const char rcsId[]="$Id$";
#include <GSWeb/GSWeb.h>
#include <GSWExtensions/GSWLongResponsePage.h>
@interface GSWLongResponsePage (Private)
-(void) _setCancelled:(BOOL)cancelled;
-(void) _setResult:(id)result;
-(id)_result;
-(void)_setException:(NSException*)exception;
-(NSException*)_exception;
@end
//===================================================================================
@implementation GSWLongResponsePage
@ -83,9 +92,9 @@ static char rcsId[] = "$Id$";
NSString *url=nil;
NSString *header=nil;
url=[aContext urlWithRequestHandlerKey:@"cr"
path:nil
queryString:nil];
url=(NSString*)[aContext urlWithRequestHandlerKey:@"cr"
path:nil
queryString:nil];
NSDebugMLog(@"url=%@",url);
header=[NSString stringWithFormat:@"%d;url=%@%@/%@.GSWMetaRefresh",
(int)_refreshInterval,
@ -276,9 +285,11 @@ Don't override it
{
//??
GSWComponent *page=nil;
id status=nil;
status=[self _status];
LOGObjectFnStartC("GSWLongResponsePage");
[self _setCancelled:YES];
page=[self cancelPage];
page=[self cancelPageForStatus:status];
LOGObjectFnStopC("GSWLongResponsePage");
return page;
};

View file

@ -1,6 +1,6 @@
/** GSWApplication.m - <title>GSWeb: Class GSWApplication</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
@ -28,6 +28,8 @@
</license>
**/
static const char rcsId[]="$Id$";
#include <GSWeb/GSWeb.h>
#if GDL2 // GDL2 implementation
#include <EOAccess/EOModelGroup.h>
@ -398,6 +400,8 @@ int GSWApplicationMainReal(NSString* applicationClassName,
ASSIGNCOPY(globalApplicationClassName,applicationClassName);
GSWApplicationDebugSetChange();
applicationClass=[GSWApplication _applicationClass];
NSDebugFLog(@"=======");
NSDebugFLog(@"applicationClass: %@",applicationClass);
if (!applicationClass)
{
NSCAssert(NO,@"!applicationClass");
@ -501,15 +505,6 @@ int GSWApplicationMain(NSString* applicationClassName,
//====================================================================
@implementation GSWApplication
//--------------------------------------------------------------------
+(void)initialize
{
if (self==[GSWApplication class])
{
//Moved In GSWApplicationMainReal
};
};
//--------------------------------------------------------------------
- (void)_setPool:(NSAutoreleasePool *)pool
{
@ -2641,12 +2636,29 @@ selfLockn,
GSWRequest* request=nil;
GSWSession* session=nil;
LOGObjectFnStart();
request=[aContext request];
session=[aContext existingSession];
[session appendToResponse:aResponse
inContext:aContext];
//call request headerForKey:@"x-gsweb-recording"
//call applic recordingPath
NS_DURING
{
request=[aContext request];
NSDebugMLog(@"request=%p",request);
session=[aContext existingSession];
NSDebugMLog(@"session=%p",session);
[session appendToResponse:aResponse
inContext:aContext];
//call request headerForKey:@"x-gsweb-recording"
//call applic recordingPath
}
NS_HANDLER
{
LOGException(@"exception in %@ appendToResponse:inContext",
[self class]);
LOGException(@"exception=%@",localException);
localException=ExceptionByAddingUserInfoObjectFrameInfo(localException,
@"In %@ appendToResponse:inContext",
[self class]);
LOGException(@"exception=%@",localException);
[localException raise];
}
NS_ENDHANDLER;
LOGObjectFnStop();
};

View file

@ -98,7 +98,6 @@ In the case value = myMember.label, value came from method "label" or member "la
+(GSWAssociation*)associationWithKeyPath:(NSString*)keyPath;
//NDFN
+(GSWAssociation*)associationFromString:(NSString*)string;
@end
/*
//====================================================================

View file

@ -1071,7 +1071,6 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
NSDebugMLLog(@"associations",@"key=%@",key);
if ([key hasPrefix:prefix])
{
[removeFrom removeObjectForKey:key];
value=[self objectForKey:key];
NSDebugMLLog(@"associations",@"value=%@",value);
varKey=[key stringByDeletingPrefix:prefix];
@ -1080,6 +1079,7 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
NSDebugMLLog(@"associations",@"varKeyAssociation=%@",varKeyAssociation);
[newAssociation setObject:value
forKey:varKeyAssociation];
[removeFrom removeObjectForKey:key];
};
};
newAssociation=[NSDictionary dictionaryWithDictionary:newAssociation];

View file

@ -1,12 +1,13 @@
/** GSWBundle.m - <title>GSWeb: Class GSWBundle</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Mar 1999
$Revision$
$Date$
$Id$
<abstract></abstract>
@ -29,7 +30,7 @@
</license>
**/
static char rcsId[] = "$Id$";
static const char rcsId[] = "$Id$";
#include <GSWeb/GSWeb.h>
@ -999,7 +1000,7 @@ objectForReference:(NSString*)keyPath
templateParserTypeObject=[archive objectForKey:@"templateParserType"];
if (templateParserTypeObject)
{
templateParserTypeObject=[NSNumber valueWithInt:[GSWTemplateParser templateParserTypeFromString:templateParserTypeObject]];
templateParserTypeObject=[NSNumber numberWithInt:[GSWTemplateParser templateParserTypeFromString:templateParserTypeObject]];
[_templateParserTypeCache setObject:templateParserTypeObject
forKey:aName];
};

View file

@ -1,12 +1,13 @@
/** GSWComponent.m - <title>GSWeb: Class GSWComponent</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
$Revision$
$Date$
$Id$
<abstract></abstract>
@ -29,7 +30,7 @@
</license>
**/
static char rcsId[] = "$Id$";
static const char rcsId[]="$Id$";
#include <GSWeb/GSWeb.h>
@ -1086,10 +1087,12 @@ associationsKeys:(NSArray*)associationsKeys
}
NS_HANDLER
{
LOGException0(@"exception in GSWComponent invokeActionForRequest:inContext");
LOGException(@"exception in %@ appendToResponse:inContext",
[self class]);
LOGException(@"exception=%@",localException);
localException=ExceptionByAddingUserInfoObjectFrameInfo(localException,
@"In GSWComponent invokeActionForRequest:inContext");
@"In %@ appendToResponse:inContext",
[self class]);
LOGException(@"exception=%@",localException);
[localException raise];
}
@ -1104,10 +1107,12 @@ associationsKeys:(NSArray*)associationsKeys
[self class],debugElementID,[aContext elementID]);
};
#endif
if(GSDebugSet(@"gswcomponents") == YES)
[aResponse appendContentString:[NSString stringWithFormat:@"\n<!-- Stop %@ -->\n",
[self _templateName]]];//TODO enlever
#ifndef NDEBUG
if(GSDebugSet(@"gswcomponents") == YES)
[aResponse appendDebugCommentContentString:[NSString stringWithFormat:@"\n<!-- Stop %@ -->\n",
[self _templateName]]];//TODO enlever
#endif
GSWAssertIsElementID(aContext);
LOGObjectFnStop();
};
@ -1137,10 +1142,12 @@ associationsKeys:(NSArray*)associationsKeys
}
NS_HANDLER
{
LOGException0(@"exception in GSWComponent invokeActionForRequest:inContext");
LOGException(@"exception in %@ invokeActionForRequest:inContext",
[self class]);
LOGException(@"exception=%@",localException);
localException=ExceptionByAddingUserInfoObjectFrameInfo(localException,
@"In GSWComponent invokeActionForRequest:inContext");
@"In %@ invokeActionForRequest:inContext",
[self class]);
LOGException(@"exception=%@",localException);
[localException raise];
}
@ -1156,7 +1163,7 @@ associationsKeys:(NSArray*)associationsKeys
#endif
// if (![aContext _wasActionInvoked] && [[[aContext elementID] parentElementIDString] compare:[aContext senderID]]==NSOrderedDescending)
if (![aContext _wasActionInvoked]
&& [[[aContext elementID] parentElementIDString] isSearchOverForSenderID:[aContext senderID]])
&& [(GSWElementIDString*)[[aContext elementID] parentElementIDString] isSearchOverForSenderID:[aContext senderID]])
{
LOGError(@"Action not invoked at the end of %@ (id=%@) senderId=%@",
[self class],
@ -1565,49 +1572,81 @@ associationsKeys:(NSArray*)associationsKeys
GSWElement* pageElement=nil;
BOOL pageChanged=NO;
LOGObjectFnStart();
response=[[GSWResponse new]autorelease];
session=[aContext existingSession];
NSDebugMLLog(@"GSWComponent",@"session=%@",session);
if (session)
NSAssert(aContext,@"No context");
NS_DURING
{
//TODO
response=[[GSWResponse new]autorelease];
[aContext deleteAllElementIDComponents];
request=[aContext request];
NSDebugMLLog(@"GSWComponent",@"request=%@",request);
httpVersion=(request ? [request httpVersion] : @"HTTP/1.0");
[response setHTTPVersion:httpVersion];
[response setHeader:@"text/html"
forKey:@"content-type"];
NSDebugMLLog(@"GSWComponent",@"response=%@",response);
[aContext _setResponse:response];
pageElement=[aContext _pageElement];
NSDebugMLLog(@"GSWComponent",@"pageElement=%@",pageElement);
pageChanged=(self!=(GSWComponent*)pageElement);
NSDebugMLLog(@"GSWComponent",@"pageChanged=%d",pageChanged);
[aContext _setPageChanged:pageChanged];
if (pageChanged)
[aContext _setPageElement:self];
[aContext _setCurrentComponent:self];
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
@"in GSWComponent -_generateResponseInContext:");
LOGException(@"%@ (%@)",localException,[localException reason]);
[localException raise];
};
[aContext deleteAllElementIDComponents];
request=[aContext request];
httpVersion=[request httpVersion];
[response setHTTPVersion:httpVersion];
[response setHeader:@"text/html"
forKey:@"content-type"];
[aContext _setResponse:response];
//====>
pageElement=[aContext _pageElement];
pageChanged=(self!=(GSWComponent*)pageElement);
[aContext _setPageChanged:pageChanged];
//====>
if (pageChanged)
[aContext _setPageElement:self];
[aContext _setCurrentComponent:self];
//====>
[self appendToResponse:response
inContext:aContext];
//----------------
//==>10
session=[aContext session];
NSDebugMLLog(@"GSWComponent",@"session=%@",session);
NSDebugMLLog(@"GSWComponent",@"sessionID=%@",[session sessionID]);
[session appendCookieToResponse:response];
//==>11
NSDebugMLLog(@"GSWComponent",@"sessionID=%@",[session sessionID]);
[session _saveCurrentPage];
[aContext _incrementContextID];
[aContext deleteAllElementIDComponents];
[aContext _setPageChanged:pageChanged];
[aContext _setPageReplaced:NO];
NSDebugMLLog(@"GSWComponent",@"sessionID=%@",[session sessionID]);
//<==========
NS_ENDHANDLER;
NS_DURING
{
[self appendToResponse:response
inContext:aContext];
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
@"in GSWComponent -_generateResponseInContext:");
LOGException(@"%@ (%@)",localException,[localException reason]);
[localException raise];
};
NS_ENDHANDLER;
NS_DURING
{
session=[aContext _session];
NSDebugMLLog(@"GSWComponent",@"session=%@",session);
if (session)
{
NSDebugMLLog(@"GSWComponent",@"sessionID=%@",[session sessionID]);
[session appendCookieToResponse:response];
NSDebugMLLog(@"GSWComponent",@"sessionID=%@",[session sessionID]);
[session _saveCurrentPage];
};
[aContext _incrementContextID];
[aContext deleteAllElementIDComponents];
[aContext _setPageChanged:YES];
//[aContext _setPageReplaced:NO];
NSDebugMLLog(@"GSWComponent",@"sessionID=%@",[session sessionID]);
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
@"in GSWComponent -_generateResponseInContext:");
LOGException(@"%@ (%@)",localException,[localException reason]);
[localException raise];
};
NS_ENDHANDLER;
LOGObjectFnStop();
return response;
};

View file

@ -1,6 +1,6 @@
/** GSWComponentRequestHandler.m - <title>GSWeb: Class GSWComponentRequestHandler</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Feb 1999
@ -27,7 +27,7 @@
</license>
**/
static char rcsId[] = "$Id$";
static const char rcsId[] = "$Id$";
#include <GSWeb/GSWeb.h>
@ -102,7 +102,7 @@ static char rcsId[] = "$Id$";
// NSDebugMLLog(@"requests",@"statisticsStore=%@",statisticsStore);
//[statisticsStore _applicationWillHandleComponentActionRequest];
aContext=[GSWContext contextWithRequest:aRequest];
NSDebugMLLog(@"aContext",@"aContext=%@",aContext);
NSDebugMLLog(@"requests",@"aContext=%@",aContext);
senderID=[requestHandlerValues objectForKey:GSWKey_ElementID[GSWebNamingConv]];
NSDebugMLLog(@"requests",@"AA senderID=%@",senderID);
[aContext _setSenderID:senderID];
@ -266,7 +266,7 @@ static char rcsId[] = "$Id$";
storesIDsInCookies=[aSession storesIDsInCookies]; //For What ?
NSDebugMLLog(@"requests",@"storesIDsInCookies=%s",(storesIDsInCookies ? "YES" : "NO"));
contextID=[elements objectForKey:GSWKey_ContextID[GSWebNamingConv]];
contextID=[elements objectForKey:GSWKey_ContextID[GSWebNamingConv]];//use aContext requestContextID instead ?
NSDebugMLLog(@"requests",@"contextID=%@",contextID);
if (contextID) // ??
@ -547,6 +547,7 @@ static char rcsId[] = "$Id$";
NS_DURING
{
values=[aRequest uriOrFormOrCookiesElements];
NSDebugMLLog(@"requests",@"values=%@",values);
}
NS_HANDLER
{

View file

@ -1,5 +1,6 @@
/* GSWConstants.h - constants
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
@ -268,6 +269,7 @@ extern id negate__Key;
extern id pageName__Key;
extern id elementName__Key;
extern id fragmentIdentifier__Key;
extern id secure__Key;
extern id string__Key;
extern id scriptFile__Key;
extern id scriptString__Key;
@ -317,7 +319,8 @@ extern id handleValidationException__Key;
extern id selectedValues__Key;
extern id startIndex__Key;
extern id stopIndex__Key;
extern id cidStore__Key;
extern id cidKey__Key;
#endif // _GSWebConstants_h__

View file

@ -1,11 +1,13 @@
/** GSWConstants.m - <title>constants</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
Date: Jan 1999
$Revision$
$Date$
$Id$
<abstract></abstract>
@ -28,7 +30,7 @@
</license>
**/
static char rcsId[] = "$Id$";
static const char rcsId[]="$Id$";
#include <GSWeb/GSWeb.h>
@ -274,6 +276,7 @@ id negate__Key = @"negate";
id pageName__Key = @"pageName";
id elementName__Key = @"elementName";
id fragmentIdentifier__Key = @"fragmentIdentifier";
id secure__Key = @"secure";
id string__Key = @"string";
id scriptFile__Key = @"scriptFile";
id scriptString__Key = @"scriptString";
@ -321,4 +324,6 @@ id handleValidationException__Key = @"handleValidationException";
id selectedValues__Key = @"selectedValues";
id startIndex__Key = @"startIndex";
id stopIndex__Key = @"stopIndex";
id cidStore__Key = @"cidStore";
id cidKey__Key = @"cidKey";

View file

@ -1,6 +1,6 @@
/** GSWContext.h - <title>GSWeb: Class GSWContext</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
@ -40,6 +40,7 @@
unsigned _contextID;
NSString* _senderID;
NSString* _requestSessionID;
NSString* _requestContextID;
GSWElementIDString* _elementID;
GSWSession* _session;
GSWRequest* _request;
@ -65,6 +66,7 @@
NSMutableString* _docStructure; //ForDebugging purpose: array of all objects if the document during appendResponse, takeValues, invokeAction
NSMutableSet* _docStructureElements;
#endif
NSMutableDictionary* _userInfo;
};
-(id)init;
@ -80,6 +82,7 @@
-(GSWComponent*)page;
-(GSWResponse*)response;
-(GSWRequest*)request;
-(GSWSession*)_session;
-(GSWSession*)session;
-(BOOL)hasSession;
-(NSString*)senderID;
@ -100,7 +103,11 @@
@interface GSWContext (GSWURLGeneration)
-(GSWDynamicURLString*)directActionURLForActionNamed:(NSString*)actionName
queryDictionary:(NSDictionary*)queryDictionary;
-(GSWDynamicURLString*)directActionURLForActionNamed:(NSString*)actionName
queryDictionary:(NSDictionary*)queryDictionary
isSecure:(BOOL)isSecure;
-(GSWDynamicURLString*)componentActionURL;
-(GSWDynamicURLString*)componentActionURLIsSecure:(BOOL)isSecure;
-(GSWDynamicURLString*)urlWithRequestHandlerKey:(NSString*)requestHandlerKey
path:(NSString*)requestHandlerPath
queryString:(NSString*)queryString;
@ -129,7 +136,12 @@
-(BOOL)_wasFormSubmitted;
-(void)_setFormSubmitted:(BOOL)flag;
-(void)_putAwakeComponentsToSleep;
-(void)_generateCompleteURLs;
-(BOOL)_generateCompleteURLs;
-(BOOL)_generateRelativeURLs;
-(GSWDynamicURLString*)_directActionURLForActionNamed:(NSString*)actionName
queryDictionary:(NSDictionary*)dict
isSecure:(BOOL)isSecure
url:(id)anURL;
-(GSWDynamicURLString*)_directActionURLForActionNamed:(NSString*)actionName
queryDictionary:(NSDictionary*)dict
url:(id)url;
@ -150,11 +162,15 @@
-(BOOL)_pageReplaced;
-(void)_setPageChanged:(BOOL)flag;
-(BOOL)_pageChanged;
-(void)_setRequestContextID:(NSString*)contextID;
-(NSString*)_requestContextID;
-(void)_setRequestSessionID:(NSString*)sessionID;
-(NSString*)_requestSessionID;
-(void)_takeAwakeComponentsFromArray:(id)unknwon;
-(void)_takeAwakeComponentsFromArray:(NSArray*)components;
-(void)_takeAwakeComponent:(GSWComponent*)aComponent;
-(NSMutableDictionary*)userInfo;
-(NSMutableDictionary*)_userInfo;
-(void)_setUserInfo:(NSMutableDictionary*)userInfo;
@end
//====================================================================

View file

@ -1,12 +1,13 @@
/** GSWContext.m - <title>GSWeb: Class GSWContext</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
$Revision$
$Date$
$Id$
This file is part of the GNUstep Web Library.
@ -27,7 +28,7 @@
</license>
**/
static char rcsId[] = "$Id$";
static const char rcsId[]="$Id$";
#include <GSWeb/GSWeb.h>
@ -59,12 +60,14 @@ static int dontTraceComponentActionURL=0;
DESTROY(_senderID);
NSDebugFLog0(@"Release GSWContext requestSessionID");
DESTROY(_requestSessionID);
NSDebugFLog0(@"Release GSWContext requestContextID");
DESTROY(_requestContextID);
NSDebugFLog0(@"Release GSWContext elementID");
DESTROY(_elementID);
if (_session)
{
NSDebugFLog(@"sessionCount=%u",[_session retainCount]);
};
{
NSDebugFLog(@"sessionCount=%u",[_session retainCount]);
};
NSDebugFLog0(@"Release GSWContext session");
DESTROY(_session);
NSDebugFLog0(@"Release GSWContext request");
@ -85,6 +88,8 @@ static int dontTraceComponentActionURL=0;
DESTROY(_docStructure);
DESTROY(_docStructureElements);
#endif
NSDebugFLog0(@"Release GSWContext userInfo");
DESTROY(_userInfo);
NSDebugFLog0(@"Dealloc GSWContext super");
[super dealloc];
NSDebugFLog0(@"end Dealloc GSWContext");
@ -125,6 +130,7 @@ static int dontTraceComponentActionURL=0;
clone->_contextID=_contextID;
ASSIGNCOPY(clone->_senderID,_senderID);
ASSIGNCOPY(clone->_requestSessionID,_requestSessionID);
ASSIGNCOPY(clone->_requestContextID,_requestContextID);
ASSIGNCOPY(clone->_elementID,_elementID);
ASSIGN(clone->_session,_session); //TODOV
ASSIGN(clone->_request,_request); //TODOV
@ -133,7 +139,10 @@ static int dontTraceComponentActionURL=0;
ASSIGN(clone->_pageComponent,_pageComponent);
ASSIGN(clone->_currentComponent,_currentComponent);
ASSIGNCOPY(clone->_url,_url);
ASSIGN(clone->_awakePageComponents,_awakePageComponents);
if (_awakePageComponents)
clone->_awakePageComponents=[_awakePageComponents mutableCopy];
if (_userInfo)
clone->_userInfo=[_userInfo mutableCopy];
clone->_urlApplicationNumber=_urlApplicationNumber;
clone->_isClientComponentRequest=_isClientComponentRequest;
clone->_distributionEnabled=_distributionEnabled;
@ -199,11 +208,7 @@ static int dontTraceComponentActionURL=0;
//--------------------------------------------------------------------
-(GSWComponent*)component
{
GSWComponent* component=nil;
// LOGObjectFnStart();
component=_currentComponent;
// LOGObjectFnStop();
return component;
return _currentComponent;
};
//--------------------------------------------------------------------
@ -219,10 +224,10 @@ static int dontTraceComponentActionURL=0;
//--------------------------------------------------------------------
-(GSWComponent*)page
{
if ([_pageComponent _isPage]) //TODOV
if ([_pageComponent _isPage])
return _pageComponent;
else
return nil;//TODOV
return nil;
};
//--------------------------------------------------------------------
@ -243,19 +248,31 @@ static int dontTraceComponentActionURL=0;
return (_session!=nil);
};
//--------------------------------------------------------------------
-(GSWSession*)_session
{
return _session;
};
//--------------------------------------------------------------------
-(GSWSession*)session
{
GSWSession* session=nil;
LOGObjectFnStart();
if (_session)
session=_session;
else
if (!_session)
{
session=[GSWApp _initializeSessionInContext:self];
NSDebugMLog(@"_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");
LOGObjectFnStop();
return session;
return _session;
};
//--------------------------------------------------------------------
@ -337,14 +354,27 @@ static int dontTraceComponentActionURL=0;
queryDictionary:(NSDictionary*)queryDictionary
{
//OK
GSWSession* session=nil;
GSWDynamicURLString* url=nil;
LOGObjectFnStart();
session=[self existingSession];
NSDebugMLog(@"url=%@",url);
url=[self directActionURLForActionNamed:actionName
queryDictionary:queryDictionary
isSecure:NO];
LOGObjectFnStop();
return url;
};
-(GSWDynamicURLString*)directActionURLForActionNamed:(NSString*)actionName
queryDictionary:(NSDictionary*)queryDictionary
isSecure:(BOOL)isSecure
{
//OK
GSWDynamicURLString* url=nil;
LOGObjectFnStart();
url=[self _directActionURLForActionNamed:actionName
queryDictionary:queryDictionary
isSecure:isSecure
url:url];
NSDebugMLog(@"url=%@",url);
LOGObjectFnStop();
return url;
};
@ -352,7 +382,15 @@ static int dontTraceComponentActionURL=0;
//--------------------------------------------------------------------
-(GSWDynamicURLString*)componentActionURL
{
//OK
GSWDynamicURLString* url=nil;
LOGObjectFnStartCond(dontTraceComponentActionURL==0);
url=[self componentActionURLIsSecure:NO];
LOGObjectFnStopCond(dontTraceComponentActionURL==0);
return url;
};
-(GSWDynamicURLString*)componentActionURLIsSecure:(BOOL)isSecure
{
//TODO: use isSecure
BOOL storesIDsInURLs=NO;
GSWDynamicURLString* url=nil;
GSWSession* session=nil;
@ -553,6 +591,7 @@ static int dontTraceComponentActionURL=0;
//--------------------------------------------------------------------
-(void)_setActionInvoked:(BOOL)flag
{
NSDebugMLLog(@"gswdync",@"Set Action invoked:%d",flag);
_actionInvoked=flag;
};
@ -571,7 +610,6 @@ static int dontTraceComponentActionURL=0;
//--------------------------------------------------------------------
-(void)_putAwakeComponentsToSleep
{
//OK TODOV
int i=0;
GSWComponent* component=nil;
LOGObjectFnStart();
@ -585,9 +623,19 @@ static int dontTraceComponentActionURL=0;
};
//--------------------------------------------------------------------
-(void)_generateCompleteURLs
-(BOOL)_generateCompleteURLs
{
BOOL previousState=_generateCompleteURLs;
_generateCompleteURLs=YES;
return previousState;
};
//--------------------------------------------------------------------
-(BOOL)_generateRelativeURLs
{
BOOL previousState=!_generateCompleteURLs;
_generateCompleteURLs=NO;
return previousState;
};
//--------------------------------------------------------------------
@ -595,6 +643,21 @@ static int dontTraceComponentActionURL=0;
-(id)_directActionURLForActionNamed:(NSString*)actionName
queryDictionary:(NSDictionary*)dict
url:(id)anURL
{
LOGObjectFnStart();
anURL=[self _directActionURLForActionNamed:actionName
queryDictionary:dict
isSecure:NO
url:anURL];
LOGObjectFnStop();
return anURL;
};
//--------------------------------------------------------------------
//_url is a semi complete one: line /cgi/WebObjects.exe/ObjCTest3.woa
-(id)_directActionURLForActionNamed:(NSString*)actionName
queryDictionary:(NSDictionary*)dict
isSecure:(BOOL)isSecure
url:(id)anURL
{
//OK
NSString* queryString=nil;
@ -603,6 +666,8 @@ static int dontTraceComponentActionURL=0;
LOGObjectFnStart();
NSDebugMLogCond(dontTraceComponentActionURL==0,
@"anURL=%@",anURL);
NSDebugMLog(@"dict=%@",dict);
// _url=[[_url copy] autorelease];
//TODOV
enumerator = [dict keyEnumerator];
@ -622,8 +687,10 @@ static int dontTraceComponentActionURL=0;
[anURL setURLQueryString:queryString];
*/
anURL=[self completeURLWithRequestHandlerKey:GSWDirectActionRequestHandlerKey[GSWebNamingConv]
path:actionName
queryString:queryString];
path:actionName
queryString:queryString
isSecure:isSecure
port:0];
NSDebugMLogCond(dontTraceComponentActionURL==0,
@"url=%@",anURL);
LOGObjectFnStop();
@ -671,9 +738,15 @@ static int dontTraceComponentActionURL=0;
-(void)_setPageElement:(GSWElement*)element
{
LOGObjectFnStart();
ASSIGN(_pageElement,element);
//TODOV
[self _setPageComponent:(GSWComponent*)element];
if (_pageElement!=element)
{
ASSIGN(_pageElement,element);
[self _setPageComponent:nil];
if ([element isKindOfClass:[GSWComponent class]])
[self _setPageComponent:(GSWComponent*)element];
};
LOGObjectFnStop();
};
@ -702,19 +775,32 @@ static int dontTraceComponentActionURL=0;
//OK
NSString* adaptorPrefix=nil;
NSString* applicationName=nil;
LOGObjectFnStart();
NSDebugMLLog(@"low",@"aRequest=%@",aRequest);
NSDebugMLLog(@"low",@"url=%@",_url);
adaptorPrefix=[aRequest adaptorPrefix];
NSDebugMLLog(@"low",@"adaptorPrefix=%@",adaptorPrefix);
[_url setURLPrefix:adaptorPrefix];
NSDebugMLLog(@"low",@"url=%@",_url);
applicationName=[aRequest applicationName];
NSDebugMLLog(@"low",@"applicationName=%@",applicationName);
[_url setURLApplicationName:applicationName];
NSDebugMLLog(@"low",@"url=%@",_url);
ASSIGN(_request,aRequest);
[self _synchronizeForDistribution];
if (_request!=aRequest)
{
NSDebugMLLog(@"low",@"aRequest=%@",aRequest);
ASSIGN(_request,aRequest);
[_request _setContext:self];
NSDebugMLLog(@"low",@"url=%@",_url);
adaptorPrefix=[aRequest adaptorPrefix];
NSDebugMLLog(@"low",@"adaptorPrefix=%@",adaptorPrefix);
[_url setURLPrefix:adaptorPrefix];
NSDebugMLLog(@"low",@"url=%@",_url);
applicationName=[aRequest applicationName];
NSDebugMLLog(@"low",@"applicationName=%@",applicationName);
[_url setURLApplicationName:applicationName];
NSDebugMLLog(@"low",@"url=%@",_url);
[self _synchronizeForDistribution];
};
LOGObjectFnStop();
};
@ -724,11 +810,17 @@ static int dontTraceComponentActionURL=0;
//OK
LOGObjectFnStart();
NSDebugMLLog(@"sessions",@"aSession ID:%@",[aSession sessionID]);
ASSIGN(_session,aSession);
[self _synchronizeForDistribution];
NSDebugMLLog(@"low",@"contextID=%u",_contextID);
_contextID=[_session _contextCounter];
NSDebugMLLog(@"low",@"contextID=%u",_contextID);
if (_session!=aSession)
{
ASSIGN(_session,aSession);
[self _synchronizeForDistribution];
};
if (_session)
{
NSDebugMLLog(@"low",@"contextID=%u",_contextID);
_contextID=[_session _contextCounter];
NSDebugMLLog(@"low",@"contextID=%u",_contextID);
};
LOGObjectFnStop();
};
@ -759,11 +851,11 @@ static int dontTraceComponentActionURL=0;
//--------------------------------------------------------------------
-(void)_incrementContextID
{
_contextID++;
[_session _contextDidIncrementContextID];
};
//--------------------------------------------------------------------
//oldname= _session
-(GSWSession*)existingSession
{
return _session;
@ -802,6 +894,18 @@ static int dontTraceComponentActionURL=0;
return _pageChanged;
};
//--------------------------------------------------------------------
-(void)_setRequestContextID:(NSString*)contextID
{
ASSIGN(_requestContextID,contextID);
}
//--------------------------------------------------------------------
-(NSString*)_requestContextID
{
return _requestContextID;
}
//--------------------------------------------------------------------
-(void)_setRequestSessionID:(NSString*)aSessionID
{
@ -817,9 +921,24 @@ static int dontTraceComponentActionURL=0;
};
//--------------------------------------------------------------------
-(void)_takeAwakeComponentsFromArray:(id)unknwon
-(void)_takeAwakeComponentsFromArray:(NSArray*)components
{
LOGObjectFnNotImplemented(); //TODOFN
LOGObjectFnStart();
if ([components count]>0)
{
NSEnumerator* enumerator = nil;
GSWComponent* component = nil;
if (!_awakePageComponents)
_awakePageComponents=[NSMutableArray new];
enumerator = [components objectEnumerator];
while ((component = [enumerator nextObject]))
{
if (![_awakePageComponents containsObject:component])
[_awakePageComponents addObject:component];
};
};
LOGObjectFnStop();
};
//--------------------------------------------------------------------
@ -827,12 +946,37 @@ static int dontTraceComponentActionURL=0;
{
//OK
LOGObjectFnStart();
NSDebugMLLog(@"low",@"component: %@",[component class]);
if (!_awakePageComponents)
_awakePageComponents=[NSMutableArray new];
[_awakePageComponents addObject:component];
if (![_awakePageComponents containsObject:component])
[_awakePageComponents addObject:component];
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(NSMutableDictionary*)userInfo
{
return [self _userInfo];
};
//--------------------------------------------------------------------
-(NSMutableDictionary*)_userInfo
{
if (!_userInfo)
_userInfo=[NSMutableDictionary new];
return _userInfo;
};
//--------------------------------------------------------------------
-(void)_setUserInfo:(NSMutableDictionary*)userInfo
{
NSAssert2(!userInfo || [userInfo isKindOfClass:[NSMutableDictionary class]],
@"userInfo is not a NSMutableDictionary but a %@: %@",
[userInfo class],
userInfo);
ASSIGN(_userInfo,userInfo);
};
@end
//====================================================================
@ -842,11 +986,9 @@ static int dontTraceComponentActionURL=0;
// incrementLastElementIDComponent
-(void)incrementLastElementIDComponent
{
// LOGObjectFnStart();
if (!_elementID)
_elementID=[GSWElementIDString new];
[_elementID incrementLastElementIDComponent];
// LOGObjectFnStop();
};
@ -855,42 +997,36 @@ static int dontTraceComponentActionURL=0;
// appendElementIDComponent:
-(void)appendElementIDComponent:(NSString*)string
{
// LOGObjectFnStart();
if (!_elementID)
_elementID=[GSWElementIDString new];
[_elementID appendElementIDComponent:string];
// LOGObjectFnStop();
};
//--------------------------------------------------------------------
// appendZeroElementIDComponent
-(void)appendZeroElementIDComponent
{
// LOGObjectFnStart();
if (!_elementID)
_elementID=[GSWElementIDString new];
[_elementID appendZeroElementIDComponent];
// LOGObjectFnStop();
};
//--------------------------------------------------------------------
// deleteAllElementIDComponents
-(void)deleteAllElementIDComponents
{
// LOGObjectFnStart();
if (!_elementID)
_elementID=[GSWElementIDString new];
[_elementID deleteAllElementIDComponents];
// LOGObjectFnStop();
};
//--------------------------------------------------------------------
// deleteLastElementIDComponent
-(void)deleteLastElementIDComponent
{
// LOGObjectFnStart();
if (!_elementID)
_elementID=[GSWElementIDString new];
[_elementID deleteLastElementIDComponent];
// LOGObjectFnStop();
};
@end
@ -963,4 +1099,5 @@ static int dontTraceComponentActionURL=0;
_isValidate = isValidate;
NSDebugMLLog(@"low",@"isValidate=%d\n",(int)isValidate);
};
@end

View file

@ -1,11 +1,12 @@
/** GSWDefaultAdaptorThread.m - <title>GSWeb: Class GSWDefaultAdaptorThread</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Feb 1999
$Revision$
$Date$
$Id$
<abstract></abstract>
@ -28,7 +29,7 @@
</license>
**/
static char rcsId[] = "$Id$";
static const char rcsId[] = "$Id$";
#include <GSWeb/GSWeb.h>
#include <unistd.h>
@ -178,6 +179,7 @@ static char rcsId[] = "$Id$";
}
NS_HANDLER
{
NSDebugMLog(@"localException=%@",localException);
LOGException(@"GSWDefaultAdaptorThread: createRequestFromData Exception:%@ (%@)",
localException,[localException reason]);
}
@ -567,8 +569,10 @@ static char rcsId[] = "$Id$";
if ([requestLineArray count]!=3)
{
ExceptionRaise(@"GSWDefaultAdaptorThread",
@"bad request first line (elements count %d != 3)",
[requestLineArray count]);
@"bad request first line (elements count %d != 3).\nrequestLine: %@\nrequestLineArray: %@",
[requestLineArray count],
requestLine,
requestLineArray);
}
else
{

View file

@ -50,6 +50,7 @@
-(id <GSWActionResults>)performActionNamed:(NSString*)actionName;
-(id)defaultAction;
-(id)existingSession;
-(NSString*)sessionIDForRequest:(GSWRequest*)aRequest;
-(void)_initializeRequestSessionIDInContext:(GSWContext*)aContext;
@end

View file

@ -1,12 +1,13 @@
/** GSWDirectAction.m - <title>GSWeb: Class GSWDirectAction</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Feb 1999
$Revision$
$Date$
$Id$
This file is part of the GNUstep Web Library.
@ -27,7 +28,7 @@
</license>
**/
static char rcsId[] = "$Id$";
static const char rcsId[] = "$Id$";
#include <GSWeb/GSWeb.h>
@ -258,22 +259,35 @@ static char rcsId[] = "$Id$";
return nil;//??
};
//--------------------------------------------------------------------
-(NSString*)sessionIDForRequest:(GSWRequest*)aRequest
{
NSString* sessionID = nil;
NSDebugMLog(@"aRequest=%@",aRequest);
if(aRequest)
sessionID = [aRequest sessionIDFromValuesOrCookieByLookingForCookieFirst:NO];
NSDebugMLog(@"sessionID=%@",sessionID);
return sessionID;
}
//--------------------------------------------------------------------
-(void)_initializeRequestSessionIDInContext:(GSWContext*)aContext
{
//OK
GSWRequest* request=nil;
NSString* gswsid=nil;
NSString* sessionID=nil;
LOGObjectFnStart();
request=[aContext request];
gswsid=[request formValueForKey:GSWKey_SessionID[GSWebNamingConv]];
if (!gswsid)
NSDebugMLog(@"request=%@",request);
sessionID=[request formValueForKey:GSWKey_SessionID[GSWebNamingConv]];
NSDebugMLog(@"sessionID=%@",sessionID);
if (!sessionID)
{
gswsid=[request cookieValueForKey:GSWKey_SessionID[GSWebNamingConv]];
sessionID=[request cookieValueForKey:GSWKey_SessionID[GSWebNamingConv]];
NSDebugMLog(@"sessionID=%@",sessionID);
};
if (gswsid)
if (sessionID)
{
//TODO
[aContext _setRequestSessionID:sessionID];
};
LOGObjectFnStop();
};

View file

@ -1,6 +1,6 @@
/** GSWForm.h - <title>GSWeb: Class GSWForm</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
@ -70,6 +70,7 @@
inContext:(GSWContext*)context;
-(NSDictionary*)computeQueryDictionaryInContext:(GSWContext*)context;
-(NSString*)computeActionStringInContext:(GSWContext*)context;
-(GSWElement*)invokeActionForRequest:(GSWRequest*)request
inContext:(GSWContext*)context;

View file

@ -1,6 +1,6 @@
/** GSWForm.m - <title>GSWeb: Class GSWForm</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
@ -27,7 +27,7 @@
</license>
**/
static char rcsId[] = "$Id$";
static const char rcsId[] = "$Id$";
#include <GSWeb/GSWeb.h>
@ -105,6 +105,16 @@ static char rcsId[] = "$Id$";
withDefaultObject:[_queryDictionary autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWForm: queryDictionary=%@",_queryDictionary);
if ([tmpAssociations count]>0)
{
ASSIGN(_otherQueryAssociations,([tmpAssociations extractObjectsForKeysWithPrefix:@"?"
removePrefix:YES]));
if ([_otherQueryAssociations count]==0)
DESTROY(_otherQueryAssociations);
};
NSDebugMLLog(@"gswdync",@"_otherQueryAssociations=%@",_otherQueryAssociations);
if ((self=[super initWithName:aName
attributeAssociations:tmpAssociations
contentElements:elements]))
@ -172,34 +182,53 @@ static char rcsId[] = "$Id$";
-(void)_appendHiddenFieldsToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
{
//OK
NSDictionary* hiddenFields=nil;
GSWRequest* request=nil;
NSString* gswsid=nil;
NSDictionary* hiddenFields = nil;
LOGObjectFnStart();
hiddenFields=[self computeQueryDictionaryInContext:context];
if (hiddenFields)
hiddenFields = [self computeQueryDictionaryInContext:context];
if([hiddenFields count]>0)
{
//TODO
NSEnumerator* enumerator=[hiddenFields keyEnumerator];
id key=nil;
while((key=[enumerator nextObject]))
{
id value=[hiddenFields objectForKey:key];
[response _appendContentAsciiString:@"<input type=hidden"];
[response _appendTagAttribute:@"name"
value:key
escapingHTMLAttributeValue:NO];//Don't escape name
[response _appendTagAttribute:@"value"
value:value
escapingHTMLAttributeValue:NO];//Don't escape value (should be escaped before !)
};
};
request=[context request];
gswsid=[request formValueForKey:GSWKey_SessionID[GSWebNamingConv]];
if (gswsid)
{
//TODO
};
LOGObjectFnNotImplemented(); //TODOFN
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(NSDictionary*)computeQueryDictionaryInContext:(GSWContext*)context
{
//OK
//GSWComponent* component=[context component];
//GSWSession* session=[context existingSession];
//NSString* sessionID=[session sessionID];
LOGObjectFnNotImplemented(); //TODOFN
return [[NSDictionary new] autorelease];
NSDictionary* queryDictionary=nil;
LOGObjectFnStart();
queryDictionary=[self computeQueryDictionaryWithActionClassAssociation:_actionClass
directActionNameAssociation:_directActionName
queryDictionaryAssociation:_queryDictionary
otherQueryAssociations:_otherQueryAssociations
inContext:context];
LOGObjectFnStop();
return queryDictionary;
};
//--------------------------------------------------------------------
-(NSString*)computeActionStringInContext:(GSWContext*)context
{
NSString* actionString=nil;
LOGObjectFnStart();
actionString=[self computeActionStringWithActionClassAssociation:_actionClass
directActionNameAssociation:_directActionName
inContext:context];
LOGObjectFnStop();
return actionString;
};
//--------------------------------------------------------------------
@ -259,7 +288,6 @@ static char rcsId[] = "$Id$";
int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb];
#endif
BOOL multipleSubmitValue=NO;
int i=0;
LOGObjectFnStartC("GSWForm");
GSWStartElement(context);
senderID=[context senderID];
@ -270,7 +298,6 @@ static char rcsId[] = "$Id$";
GSWAssertCorrectElementID(context);// Debug Only
if ([self prefixMatchSenderIDInContext:context]) //Avoid trying to find action if we are not the good component
{
BOOL searchIsOver=NO;
isFormSubmited=[elementID isEqualToString:senderID];
NSDebugMLLog(@"gswdync",@"ET=%@ defName=%@ \n id=%@ \nsenderId=%@ \nisFormSubmited=%s",
[self class],
@ -312,18 +339,33 @@ static char rcsId[] = "$Id$";
[context incrementLastElementIDComponent];
};
*/
NSDebugMLLog(@"gswdync",@"isFormSubmited=%d",isFormSubmited);
element=[super invokeActionForRequest:request
inContext:context];
NSDebugMLLog(@"gswdync",@"isFormSubmited=%d",isFormSubmited);
NSDebugMLLog(@"gswdync",@"[context _wasActionInvoked]=%d",[context _wasActionInvoked]);
if (isFormSubmited)
{
if ([context _wasActionInvoked])
[context _setIsMultipleSubmitForm:NO];
else
NSDebugMLLog(@"gswdync",@"ET=%@ defName=%@ \n id=%@ \nsenderId=%@ \nmultipleSubmit=%s \n[context _wasActionInvoked]=%d",
[self class],
[self definitionName],
elementID,
senderID,
(multipleSubmitValue ? "YES" : "NO"),
[context _wasActionInvoked]);
if (_action && ![context _wasActionInvoked])
{
NSDebugMLLog0(@"gswdync",@"formSubmitted but no action was invoked!");
GSWComponent* component=[context component];
element = (GSWElement*)[_action valueInComponent:component];
[context _setActionInvoked:YES];
};
[context setInForm:NO];
[context _setFormSubmitted:NO];
[context _setIsMultipleSubmitForm:NO];
};
elementID=[context elementID];
GSWStopElement(context);
@ -367,7 +409,6 @@ static char rcsId[] = "$Id$";
NSString* senderID=nil;
NSString* elementID=nil;
BOOL isFormSubmited=NO;
int i=0;
#ifndef NDEBBUG
int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb];
#endif
@ -420,7 +461,6 @@ static char rcsId[] = "$Id$";
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
{
//OK//TODOV
BOOL disabledInContext=NO;
LOGObjectFnStartC("GSWForm");
if (!WOStrictFlag)
@ -431,17 +471,26 @@ static char rcsId[] = "$Id$";
if (!disabledInContext)
{
GSWComponent* component=[context component];
id actionValue=nil;
if (_href)
actionValue=[_href valueInComponent:component];
{
id actionValue=[_href valueInComponent:component];
//TODO emit a warning !
[response _appendTagAttribute:@"action"
value:actionValue
escapingHTMLAttributeValue:NO];
}
else if (_directActionName || _actionClass)
{
[self _appendCGIActionToResponse:response
inContext:context];
}
else
actionValue=[context componentActionURL];
[response appendContentCharacter:' '];
[response _appendContentAsciiString:@"action"];
[response appendContentCharacter:'='];
[response appendContentCharacter:'"'];
[response appendContentString:actionValue];
[response appendContentCharacter:'"'];
{
id actionValue=[context componentActionURL];
[response _appendTagAttribute:@"action"
value:actionValue
escapingHTMLAttributeValue:NO];
};
};
LOGObjectFnStopC("GSWForm");
};
@ -450,7 +499,23 @@ static char rcsId[] = "$Id$";
-(void)_appendCGIActionToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
{
LOGObjectFnNotImplemented(); //TODOFN
NSString* actionString=nil;
NSString* anUrl=nil;
LOGObjectFnStartC("GSWForm");
actionString=[self computeActionStringInContext:context];
NSDebugMLLog(@"gswdync",@"actionString=%@",actionString);
anUrl=(NSString*)[context directActionURLForActionNamed:actionString
queryDictionary:nil
isSecure:NO];
NSDebugMLLog(@"gswdync",@"anUrl=%@",anUrl);
[response _appendTagAttribute:@"action"
value:anUrl
escapingHTMLAttributeValue:NO];
LOGObjectFnStopC("GSWForm");
};
@end

View file

@ -111,4 +111,15 @@ attributeAssociations:(NSDictionary*)attributeAssociations
+(BOOL)hasGSWebObjectsAssociations;
@end
//====================================================================
@interface GSWHTMLDynamicElement (GSWHTMLDynamicElementD)
-(NSString*)computeActionStringWithActionClassAssociation:(GSWAssociation*)actionClass
directActionNameAssociation:(GSWAssociation*)directActionName
inContext:(GSWContext*)context;
-(NSDictionary*)computeQueryDictionaryWithActionClassAssociation:(GSWAssociation*)actionClass
directActionNameAssociation:(GSWAssociation*)directActionName
queryDictionaryAssociation:(GSWAssociation*)queryDictionary
otherQueryAssociations:(NSDictionary*)otherQueryAssociations
inContext:(GSWContext*)context;
@end
#endif

View file

@ -1,12 +1,13 @@
/** GSWHTMLDynamicElement.m - <title>GSWeb: Class GSWHTMLDynamicElement</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Feb 1999
$Revision$
$Date$
$Id$
<abstract></abstract>
@ -29,7 +30,7 @@
</license>
**/
static char rcsId[] = "$Id$";
static const char rcsId[]="$Id$";
#include <GSWeb/GSWeb.h>
@ -111,7 +112,11 @@ attributeAssociations:(NSDictionary*)attributeAssociations
[htmlBareStrings addObject:[NSString stringWithString:@"="]];
[elementsMap appendBytes:&ElementsMap_htmlBareString
length:1];
[htmlBareStrings addObject:[NSString stringWithFormat:@"%@",associationValue]];
associationValue=[NSString stringWithFormat:@"%@",associationValue];
// Parser remove "";
if ([associationValue hasPrefix:@"\""])
associationValue=[NSString stringWithFormat:@"\"%@\"",associationValue];
[htmlBareStrings addObject:associationValue];
[elementsMap appendBytes:&ElementsMap_htmlBareString
length:1];
}
@ -738,3 +743,128 @@ attributeAssociations:(NSDictionary*)attributeAssociations
@end
//====================================================================
//@implementation GSWHTMLDynamicElement (GSWHTMLDynamicElementD)
// move it to GSWHTMLDynamicElement later !!!!
@implementation GSWDynamicElement (GSWHTMLDynamicElementD)
//--------------------------------------------------------------------
-(NSString*)computeActionStringWithActionClassAssociation:(GSWAssociation*)actionClass
directActionNameAssociation:(GSWAssociation*)directActionName
inContext:(GSWContext*)context
{
//OK
GSWComponent* component=nil;
id tmpDirectActionString=nil;
id directActionNameValue=nil;
id actionClassValue=nil;
LOGObjectFnStart();
component=[context component];
if (directActionName)
directActionNameValue=[directActionName valueInComponent:component];
if (actionClass)
actionClassValue=[actionClass valueInComponent:component];
if (actionClassValue)
{
if (directActionNameValue)
tmpDirectActionString=[NSString stringWithFormat:@"%@/%@",
actionClassValue,
directActionNameValue];
else
tmpDirectActionString=actionClassValue;
}
else if (directActionNameValue)
tmpDirectActionString=directActionNameValue;
else
{
LOGSeriousError(@"No actionClass (for %@) and no directActionName (for %@)",
actionClass,
directActionName);
};
NSDebugMLLog(@"gswdync",@"tmpDirectActionString=%@",tmpDirectActionString);
LOGObjectFnStop();
return tmpDirectActionString;
};
//--------------------------------------------------------------------
-(NSDictionary*)computeQueryDictionaryWithActionClassAssociation:(GSWAssociation*)actionClass
directActionNameAssociation:(GSWAssociation*)directActionName
queryDictionaryAssociation:(GSWAssociation*)queryDictionary
otherQueryAssociations:(NSDictionary*)otherQueryAssociations
inContext:(GSWContext*)context
{
//OK
NSMutableDictionary* finalQueryDictionary=nil;
GSWComponent* component=nil;
GSWSession* session=nil;
NSString* sessionID=nil;
LOGObjectFnStart();
NSDebugMLLog(@"gswdync",@"actionClass=%@",actionClass);
NSDebugMLLog(@"gswdync",@"directActionName=%@",directActionName);
NSDebugMLLog(@"gswdync",@"queryDictionary=%@",queryDictionary);
NSDebugMLLog(@"gswdync",@"otherQueryAssociations=%@",otherQueryAssociations);
component=[context component];
session=[context existingSession];
NSDebugMLog(@"session=%@",session);
if (queryDictionary)
{
NSDictionary* queryDictionaryValue=[queryDictionary valueInComponent:component];
if (queryDictionaryValue)
{
if ([queryDictionaryValue isKindOfClass:[NSMutableDictionary class]])
finalQueryDictionary=(NSMutableDictionary*)queryDictionaryValue;
else
{
NSAssert3([queryDictionaryValue isKindOfClass:[NSDictionary class]],
@"queryDictionary value is not a dictionary but a %@. association was: %@. queryDictionaryValue is:",
[queryDictionaryValue class],
queryDictionary,
queryDictionaryValue);
finalQueryDictionary=[[queryDictionaryValue mutableCopy] autorelease];
};
};
};
if (!finalQueryDictionary)
finalQueryDictionary=(NSMutableDictionary*)[NSMutableDictionary dictionary];
if (session)
sessionID=[session sessionID];
NSDebugMLog(@"sessionID=%@",sessionID);
/*
in GSWHyperlink, it was
if (!_action && !_pageName
&& (WOStrictFlag || (!WOStrictFlag && !_redirectURL))) //??
*/
if(sessionID
&& (directActionName || actionClass)
&& (!session || ![session storesIDsInCookies] || [session storesIDsInURLs]))
[finalQueryDictionary setObject:sessionID
forKey:GSWKey_SessionID[GSWebNamingConv]];
if (otherQueryAssociations)
{
NSEnumerator *enumerator = [otherQueryAssociations keyEnumerator];
id associationKey=nil;
while ((associationKey = [enumerator nextObject]))
{
id association = [otherQueryAssociations valueForKey:associationKey];
id associationValue=[association valueInComponent:component];
NSDebugMLLog(@"gswdync",@"associationKey=%@",associationKey);
NSDebugMLLog(@"gswdync",@"association=%@",association);
NSDebugMLLog(@"gswdync",@"associationValue=%@",associationValue);
if (!associationValue)
associationValue=[NSString string];
[finalQueryDictionary setObject:associationValue
forKey:associationKey];
};
};
LOGObjectFnStop();
return finalQueryDictionary;
};
@end

View file

@ -1,6 +1,6 @@
/** GSWHTMLURLValuedElement.m - <title>GSWeb: Class GSWHTMLURLValuedElement</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Apr 1999
@ -41,6 +41,8 @@
//GSWeb Additions {
NSDictionary* _pageSetVarAssociations;
GSWAssociation* _pageSetVarAssociationsDynamic;
GSWAssociation* _cidStore;
GSWAssociation* _cidKey;
// }
GSWAssociation* _filename;
GSWAssociation* _framework;
@ -76,9 +78,27 @@
inContext:(GSWContext*)aContext;
-(void)_appendCGIActionURLToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext;
-(id)computeActionStringInContext:(GSWContext*)aContext;
-(id)computeQueryDictionaryInContext:(GSWContext*)aContext;
-(NSString*)computeActionStringInContext:(GSWContext*)aContext;
-(NSDictionary*)computeQueryDictionaryInContext:(GSWContext*)aContext;
-(NSString*)frameworkNameInContext:(GSWContext*)aContext;
@end
//====================================================================
@interface GSWHTMLURLValuedElement (GSWHTMLURLValuedElementCID)
-(NSString*)addCIDElement:(NSDictionary*)cidElement
forKey:(NSString*)cidKeyValue
forCIDStore:(GSWAssociation*)cidStore
inContext:(GSWContext*)aContext;
-(NSString*)addURL:(NSString*)url
forCIDStore:(GSWAssociation*)cidStore
inContext:(GSWContext*)aContext;
-(NSString*)addURLValuedElementData:(GSWURLValuedElementData*)data
forCIDStore:(GSWAssociation*)cidStore
inContext:(GSWContext*)aContext;
-(NSString*)addPath:(NSString*)path
forCIDStore:(GSWAssociation*)cidStore
inContext:(GSWContext*)aContext;
@end
#endif // _GSWHTMLURLValuedElement_h__

View file

@ -1,12 +1,13 @@
/** GSWHTMLURLValuedElement.m - <title>GSWeb: Class GSWHTMLURLValuedElement</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Apr 1999
$Revision$
$Date$
$Id$
This file is part of the GNUstep Web Library.
@ -27,9 +28,10 @@
</license>
**/
static char rcsId[] = "$Id$";
static const char rcsId[] = "$Id$";
#include <GSWeb/GSWeb.h>
#include <gscrypt/GSMD5.h>
//====================================================================
@implementation GSWHTMLURLValuedElement
@ -48,47 +50,47 @@ static char rcsId[] = "$Id$";
associations=[NSMutableDictionary dictionaryWithDictionary:inAssociations];
_src = [[inAssociations objectForKey:src__Key
_src = [[associations objectForKey:src__Key
withDefaultObject:[_src autorelease]] retain];
NSDebugMLLog(@"gswdync",@"src=%@",_src);
_value = [[inAssociations objectForKey:value__Key
_value = [[associations objectForKey:value__Key
withDefaultObject:[_value autorelease]] retain];
NSDebugMLLog(@"gswdync",@"value=%@",_value);
_pageName = [[inAssociations objectForKey:pageName__Key
_pageName = [[associations objectForKey:pageName__Key
withDefaultObject:[_pageName autorelease]] retain];
NSDebugMLLog(@"gswdync",@"pageName=%@",_pageName);
_filename = [[inAssociations objectForKey:filename__Key
_filename = [[associations objectForKey:filename__Key
withDefaultObject:[_filename autorelease]] retain];
NSDebugMLLog(@"gswdync",@"filename=%@",_filename);
_framework = [[inAssociations objectForKey:framework__Key
_framework = [[associations objectForKey:framework__Key
withDefaultObject:[_framework autorelease]] retain];
NSDebugMLLog(@"gswdync",@"framework=%@",_framework);
_data = [[inAssociations objectForKey:data__Key
_data = [[associations objectForKey:data__Key
withDefaultObject:[_data autorelease]] retain];
NSDebugMLLog(@"gswdync",@"data=%@",_data);
_mimeType = [[inAssociations objectForKey:mimeType__Key
_mimeType = [[associations objectForKey:mimeType__Key
withDefaultObject:[_mimeType autorelease]] retain];
NSDebugMLLog(@"gswdync",@"mimeType=%@",_mimeType);
_key = [[inAssociations objectForKey:key__Key
_key = [[associations objectForKey:key__Key
withDefaultObject:[_key autorelease]] retain];
NSDebugMLLog(@"gswdync",@"key=%@",_key);
_actionClass = [[inAssociations objectForKey:actionClass__Key
_actionClass = [[associations objectForKey:actionClass__Key
withDefaultObject:[_actionClass autorelease]] retain];
NSDebugMLLog(@"gswdync",@"actionClass=%@",_actionClass);
_directActionName = [[inAssociations objectForKey:directActionName__Key
_directActionName = [[associations objectForKey:directActionName__Key
withDefaultObject:[_directActionName autorelease]] retain];
NSDebugMLLog(@"gswdync",@"directActionName=%@",_directActionName);
_queryDictionary = [[inAssociations objectForKey:queryDictionary__Key
_queryDictionary = [[associations objectForKey:queryDictionary__Key
withDefaultObject:[_queryDictionary autorelease]] retain];
NSDebugMLLog(@"gswdync",@"queryDictionary=%@",_queryDictionary);
@ -106,17 +108,38 @@ static char rcsId[] = "$Id$";
if (!WOStrictFlag)
{
//pageSetVarAssociations//GNUstepWeb only
NSDictionary* pageSetVarAssociations=[inAssociations associationsWithoutPrefix:pageSetVar__Prefix__Key
NSDictionary* pageSetVarAssociations=[associations associationsWithoutPrefix:pageSetVar__Prefix__Key
removeFrom:associations];
if ([pageSetVarAssociations count]>0)
{
ASSIGN(_pageSetVarAssociations,pageSetVarAssociations);
};
_pageSetVarAssociationsDynamic=[[inAssociations objectForKey:pageSetVars__Key
_pageSetVarAssociationsDynamic=[[associations objectForKey:pageSetVars__Key
withDefaultObject:[_pageSetVarAssociationsDynamic autorelease]] retain];
NSDebugMLLog(@"gswdync",@"_pageSetVarAssociationsDynamic=%@",_pageSetVarAssociationsDynamic);
_cidStore = [[associations objectForKey:cidStore__Key
withDefaultObject:[_cidStore autorelease]] retain];
NSDebugMLLog(@"gswdync",@"cidStore=%@",_cidStore);
_cidKey = [[associations objectForKey:cidKey__Key
withDefaultObject:[_cidKey autorelease]] retain];
NSDebugMLLog(@"gswdync",@"cidKey=%@",_cidKey);
[associations removeObjectForKey:pageSetVars__Key];
[associations removeObjectForKey:cidStore__Key];
[associations removeObjectForKey:cidKey__Key];
};
if ([associations count]>0)
{
ASSIGN(_otherQueryAssociations,([associations extractObjectsForKeysWithPrefix:@"?"
removePrefix:YES]));
if ([_otherQueryAssociations count]==0)
DESTROY(_otherQueryAssociations);
};
if ((self=[super initWithName:[self elementName]//NEW
attributeAssociations:associations
contentElements:elements]))
@ -143,6 +166,8 @@ static char rcsId[] = "$Id$";
DESTROY(_directActionName);
DESTROY(_queryDictionary);
DESTROY(_otherQueryAssociations);
DESTROY(_cidStore);//GSWeb only
DESTROY(_cidKey);//GSWeb only
[super dealloc];
}
@ -262,25 +287,59 @@ static char rcsId[] = "$Id$";
NSString* keyValue=nil;
id data=nil;
id mimeTypeValue=nil;
id cidStoreValue=nil;
GSWURLValuedElementData* dataValue=nil;
GSWResourceManager* resourceManager=nil;
LOGObjectFnStartC("GSWHTMLURLValuedElement");
LOGObjectFnStartC("GSWHTMLURLValuedElement");
NS_DURING
{
NSDebugMLLog(@"gswdync",@"elementID=%@",[aContext elementID]);
component=[aContext component];
NSDebugMLLog(@"gswdync",@"data=%@",_data);
NSDebugMLLog(@"gswdync",@"filename=%@",_filename);
NSDebugMLLog(@"gswdync",@"pageName=%@",_pageName);
cidStoreValue=[_cidStore valueInComponent:component];
NSDebugMLLog(@"gswdync",@"cidStoreValue=%@",cidStoreValue);
resourceManager=[[GSWApplication application]resourceManager];
if (_src)
url=[_src valueInComponent:component];
{
url=[_src valueInComponent:component];
NSDebugMLLog(@"gswdync",@"url=%@",url);
if (cidStoreValue)
{
url=[self addURL:url
forCIDStore:_cidStore
inContext:aContext];
NSDebugMLLog(@"gswdync",@"url=%@",url);
};
}
else if (_actionClass || _directActionName)
{
url=(NSString*)[aContext componentActionURL];
NSDebugMLLog(@"gswdync",@"url=%@",url);
if (cidStoreValue)
{
url=[self addURL:url
forCIDStore:_cidStore
inContext:aContext];
NSDebugMLLog(@"gswdync",@"url=%@",url);
};
}
else
{
BOOL processed=NO;
if (_key)
{
keyValue=[_key valueInComponent:component];
NSDebugMLLog(@"gswdync",@"keyValue=%@",keyValue);
dataValue=[resourceManager _cachedDataForKey:keyValue];
NSDebugMLLog(@"gswdync",@"dataValue=%@",dataValue);
};
if (!dataValue && _data)
if (_data && !dataValue)
{
data=[_data valueInComponent:component];
NSDebugMLLog(@"gswdync",@"_data=%@",data);
@ -292,8 +351,16 @@ static char rcsId[] = "$Id$";
key:nil] autorelease];
NSDebugMLLog(@"gswdync",@"dataValue=%@",dataValue);
[resourceManager setURLValuedElementData:dataValue];
processed=YES;
}
else if (_filename)
if (cidStoreValue && dataValue)
{
url=[self addURLValuedElementData:dataValue
forCIDStore:_cidStore
inContext:aContext];
NSDebugMLLog(@"gswdync",@"url=%@",url);
}
if (!processed && _filename)
{
//Exemple: Body with filename
id filenameValue=nil;
@ -307,10 +374,24 @@ static char rcsId[] = "$Id$";
NSDebugMLLog(@"gswdync",@"frameworkValue=%@",frameworkValue);
request=[aContext request];
languages=[aContext languages];
url=[resourceManager urlForResourceNamed:filenameValue
inFramework:frameworkValue
languages:languages
request:request];
if (cidStoreValue)
{
NSString* path=[resourceManager pathForResourceNamed:filenameValue
inFramework:frameworkValue
languages:languages];
url=[self addPath:path
forCIDStore:_cidStore
inContext:aContext];
NSDebugMLLog(@"gswdync",@"url=%@",url);
}
else
{
url=[resourceManager urlForResourceNamed:filenameValue
inFramework:frameworkValue
languages:languages
request:request];
NSDebugMLLog(@"gswdync",@"url=%@",url);
};
};
};
[aResponse appendContentCharacter:' '];
@ -324,28 +405,40 @@ static char rcsId[] = "$Id$";
{
[aResponse appendContentString:url];
}
else if (_actionClass || _directActionName)
{
[aResponse appendContentString:url];
}
else
{
if (_key || _data)
{
[dataValue appendDataURLToResponse:aResponse
inContext:aContext];
if (cidStoreValue)
[aResponse appendContentString:url];
else
[dataValue appendDataURLToResponse:aResponse
inContext:aContext];
}
else if (_filename)
{
NSDebugMLLog(@"gswdync",@"url = %@",url);
[aResponse appendContentString:url];
}
else
{
GSWDynamicURLString* componentActionURL=[aContext componentActionURL];
NSDebugMLLog(@"gswdync",@"componentActionURL=%@",componentActionURL);
[aResponse appendContentString:(NSString*)componentActionURL];
};
};
if (urlAttributeName)
[aResponse appendContentCharacter:'"'];
NSDebugMLLog(@"gswdync",@"_elementID=%@",[aContext elementID]);
}
NS_HANDLER
{
LOGException0(@"exception in GSWHTMLURLValuedElement appendToResponse:inContext");
LOGException(@"exception=%@",localException);
localException=ExceptionByAddingUserInfoObjectFrameInfo(localException,
@"In GSWHTMLURLValuedElement appendToResponse:inContext");
LOGException(@"exception=%@",localException);
[localException raise];
}
NS_ENDHANDLER;
LOGObjectFnStopC("GSWHTMLURLValuedElement");
};
@ -364,21 +457,51 @@ static char rcsId[] = "$Id$";
-(void)_appendCGIActionURLToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
LOGObjectFnNotImplemented(); //TODOFN
//OK
NSString* actionString=nil;
NSDictionary* queryDictionary=nil;
NSString* anUrl=nil;
LOGObjectFnStart();
actionString=[self computeActionStringInContext:aContext];
NSDebugMLLog(@"gswdync",@"actionString=%@",actionString);
queryDictionary=[self computeQueryDictionaryInContext:aContext];
NSDebugMLLog(@"gswdync",@"queryDictionary=%@",queryDictionary);
anUrl=(NSString*)[aContext directActionURLForActionNamed:actionString
queryDictionary:queryDictionary];
NSDebugMLLog(@"gswdync",@"anUrl=%@",anUrl);
[aResponse appendContentString:anUrl];
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(id)computeActionStringInContext:(GSWContext*)aContext
-(NSString*)computeActionStringInContext:(GSWContext*)aContext
{
LOGObjectFnNotImplemented(); //TODOFN
return nil;
NSString* actionString=nil;
LOGObjectFnStart();
actionString=[self computeActionStringWithActionClassAssociation:_actionClass
directActionNameAssociation:_directActionName
inContext:aContext];
LOGObjectFnStop();
return actionString;
};
//--------------------------------------------------------------------
-(id)computeQueryDictionaryInContext:(GSWContext*)aContext
-(NSDictionary*)computeQueryDictionaryInContext:(GSWContext*)aContext
{
LOGObjectFnNotImplemented(); //TODOFN
return nil;
NSDictionary* queryDictionary=nil;
LOGObjectFnStart();
queryDictionary=[self computeQueryDictionaryWithActionClassAssociation:_actionClass
directActionNameAssociation:_directActionName
queryDictionaryAssociation:_queryDictionary
otherQueryAssociations:_otherQueryAssociations
inContext:aContext];
LOGObjectFnStop();
return queryDictionary;
};
//--------------------------------------------------------------------
@ -395,3 +518,139 @@ static char rcsId[] = "$Id$";
return frameworkName;
};
@end
//====================================================================
@implementation GSWHTMLURLValuedElement (GSWHTMLURLValuedElementCID)
-(NSString*)addCIDElement:(NSDictionary*)cidElement
forKey:(NSString*)cidKeyValue
forCIDStore:(GSWAssociation*)cidStore
inContext:(GSWContext*)aContext
{
NSString* newURL=nil;
LOGObjectFnStart();
NSDebugMLog(@"cidElement=%@",cidElement);
NSDebugMLog(@"cidKeyValue=%@",cidKeyValue);
NSDebugMLog(@"cidStore=%@",cidStore);
if (cidElement && cidStore)
{
id cidObject=nil;
GSWComponent* component=[aContext component];
cidObject=[_cidStore valueInComponent:component];
NSDebugMLog(@"cidObject=%@",cidObject);
/* if (!cidObject)
{
cidObject=(NSMutableDictionary*)[NSMutableDictionary dictionary];
[_cidStore setValue:cidObject
inComponent:component];
};
*/
if (cidObject)
{
if (![cidObject valueForKey:cidKeyValue])
[cidObject takeValue:cidElement
forKey:cidKeyValue];
newURL=[NSString stringWithFormat:@"cid:%@",
cidKeyValue];
};
NSDebugMLog(@"newURL=%@",newURL);
};
LOGObjectFnStop();
return newURL;
};
//--------------------------------------------------------------------
-(NSString*)addURL:(NSString*)url
forCIDStore:(GSWAssociation*)cidStore
inContext:(GSWContext*)aContext
{
NSString* newURL=nil;
LOGObjectFnStart();
if (url && cidStore)
{
NSString* cidKeyValue=nil;
GSWComponent* component=[aContext component];
cidKeyValue=(NSString*)[_cidKey valueInComponent:component];
NSDebugMLLog(@"gswdync",@"cidKeyValue=%@",cidKeyValue);
if (!cidKeyValue)
{
// We calculate cidKeyValue by computing md5 on path
// so there will be no duplicate elements with different keys
cidKeyValue=DataToHexString([GSMD5 digestOfString:url
usingEncoding:NSISOLatin1StringEncoding]);
};
newURL=[self addCIDElement:[NSDictionary dictionaryWithObject:url
forKey:@"url"]
forKey:cidKeyValue
forCIDStore:cidStore
inContext:aContext];
}
LOGObjectFnStop();
return newURL;
};
//--------------------------------------------------------------------
-(NSString*)addURLValuedElementData:(GSWURLValuedElementData*)data
forCIDStore:(GSWAssociation*)cidStore
inContext:(GSWContext*)aContext
{
NSString* newURL=nil;
LOGObjectFnStart();
if (data && cidStore)
{
NSString* cidKeyValue=nil;
GSWComponent* component=[aContext component];
cidKeyValue=(NSString*)[_cidKey valueInComponent:component];
NSDebugMLLog(@"gswdync",@"cidKeyValue=%@",cidKeyValue);
if (!cidKeyValue)
{
// We calculate cidKeyValue by computing md5 on path
// so there will be no duplicate elements with different keys
//NSString* cidKeyValue=DataToHexString([GSMD5 digestOfData:data]);
cidKeyValue=[data key];
};
newURL=[self addCIDElement:[NSDictionary dictionaryWithObject:data
forKey:@"data"]
forKey:cidKeyValue
forCIDStore:cidStore
inContext:aContext];
}
LOGObjectFnStop();
return newURL;
};
//--------------------------------------------------------------------
-(NSString*)addPath:(NSString*)path
forCIDStore:(GSWAssociation*)cidStore
inContext:(GSWContext*)aContext
{
NSString* newURL=nil;
LOGObjectFnStart();
if (path && cidStore)
{
NSString* cidKeyValue=nil;
GSWComponent* component=[aContext component];
cidKeyValue=(NSString*)[_cidKey valueInComponent:component];
NSDebugMLLog(@"gswdync",@"cidKeyValue=%@",cidKeyValue);
if (!cidKeyValue)
{
// We calculate cidKeyValue by computing md5 on path
// so there will be no duplicate elements with different keys
cidKeyValue=DataToHexString([GSMD5 digestOfString:path
usingEncoding:NSISOLatin1StringEncoding]);
};
newURL=[self addCIDElement:[NSDictionary dictionaryWithObject:path
forKey:@"filePath"]
forKey:cidKeyValue
forCIDStore:cidStore
inContext:aContext];
}
LOGObjectFnStop();
return newURL;
};
@end

View file

@ -1,6 +1,6 @@
/** GSWHyperlink.h - <title>GSWeb: Class GSWHyperlink</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
@ -41,6 +41,7 @@
GSWAssociation* _href;
GSWAssociation* _disabled;
GSWAssociation* _fragmentIdentifier;
GSWAssociation* _secure;
GSWAssociation* _queryDictionary;
GSWAssociation* _actionClass;
GSWAssociation* _directActionName;
@ -72,24 +73,26 @@
@end
@interface GSWHyperlink (GSWHyperlinkA)
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context;
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext;
#if !GSWEB_STRICT
-(NSString*)frameworkNameInContext:(GSWContext*)context;
-(NSString*)frameworkNameInContext:(GSWContext*)aContext;
#endif
-(void)_appendCGIActionURLToResponse:(GSWResponse*)response
inContext:(GSWContext*)context;
-(id)computeActionStringInContext:(GSWContext*)context;
-(void)_appendQueryStringToResponse:(GSWResponse*)response
inContext:(GSWContext*)context;
-(NSDictionary*)computeQueryDictionaryInContext:(GSWContext*)context;
-(NSString*)hrefInContext:(GSWContext*)context; //NDFN
-(void)_appendCGIActionURLToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext;
-(NSString*)computeActionStringInContext:(GSWContext*)aContext;
-(void)_appendQueryStringToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext;
-(NSDictionary*)computeQueryDictionaryInContext:(GSWContext*)aContext;
-(void)_appendFragmentToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext;
-(NSString*)hrefInContext:(GSWContext*)aContext; //NDFN
@end
@interface GSWHyperlink (GSWHyperlinkB)
-(GSWElement*)invokeActionForRequest:(GSWRequest*)request_
inContext:(GSWContext*)context_;
-(GSWElement*)invokeActionForRequest:(GSWRequest*)aRequest
inContext:(GSWContext*)aContext;
@end
#endif //_GSWHyperlink_h__

View file

@ -1,12 +1,13 @@
/** GSWHyperlink.m - <title>GSWeb: Class GSWHyperlink</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
$Revision$
$Date$
$Id$
This file is part of the GNUstep Web Library.
@ -27,7 +28,7 @@
</license>
**/
static char rcsId[] = "$Id$";
static const char rcsId[]="$Id$";
#include <GSWeb/GSWeb.h>
@ -67,6 +68,10 @@ static char rcsId[] = "$Id$";
withDefaultObject:[_fragmentIdentifier autorelease]] retain];
NSDebugMLLog(@"gswdync",@"fragmentIdentifier=%@",_fragmentIdentifier);
_secure = [[anAssociationsDict objectForKey:secure__Key
withDefaultObject:[_secure autorelease]] retain];
NSDebugMLLog(@"gswdync",@"secure=%@",_secure);
_queryDictionary = [[anAssociationsDict objectForKey:queryDictionary__Key
withDefaultObject:[_queryDictionary autorelease]] retain];
NSDebugMLLog(@"gswdync",@"queryDictionary=%@",_queryDictionary);
@ -97,7 +102,7 @@ static char rcsId[] = "$Id$";
_redirectURL = [[anAssociationsDict objectForKey:redirectURL__Key
withDefaultObject:[_redirectURL autorelease]] retain];
NSDebugMLLog(@"gswdync",@"redirectURL=%@",_redirectURL);
_filename = [[anAssociationsDict objectForKey:filename__Key
withDefaultObject:[_filename autorelease]] retain];
NSDebugMLLog(@"gswdync",@"filename=%@",_filename);
@ -119,6 +124,7 @@ static char rcsId[] = "$Id$";
NSDebugMLLog(@"gswdync",@"key=%@",_key);
};
tmpOtherAssociations=[NSMutableDictionary dictionaryWithDictionary:anAssociationsDict];
[tmpOtherAssociations removeObjectForKey:action__Key];
[tmpOtherAssociations removeObjectForKey:string__Key];
@ -126,6 +132,7 @@ static char rcsId[] = "$Id$";
[tmpOtherAssociations removeObjectForKey:href__Key];
[tmpOtherAssociations removeObjectForKey:disabled__Key];
[tmpOtherAssociations removeObjectForKey:fragmentIdentifier__Key];
[tmpOtherAssociations removeObjectForKey:secure__Key];
[tmpOtherAssociations removeObjectForKey:queryDictionary__Key];
[tmpOtherAssociations removeObjectForKey:actionClass__Key];
[tmpOtherAssociations removeObjectForKey:directActionName__Key];
@ -133,7 +140,7 @@ static char rcsId[] = "$Id$";
{
[tmpOtherAssociations removeObjectForKey:enabled__Key];
[tmpOtherAssociations removeObjectForKey:redirectURL__Key];
[tmpOtherAssociations removeObjectForKey:filename__Key];
[tmpOtherAssociations removeObjectForKey:framework__Key];
[tmpOtherAssociations removeObjectForKey:data__Key];
@ -157,10 +164,39 @@ static char rcsId[] = "$Id$";
};
if ([tmpOtherAssociations count]>0)
_otherAssociations=[[NSDictionary dictionaryWithDictionary:tmpOtherAssociations] retain];
{
ASSIGN(_otherQueryAssociations,([tmpOtherAssociations extractObjectsForKeysWithPrefix:@"?"
removePrefix:YES]));
if ([_otherQueryAssociations count]==0)
DESTROY(_otherQueryAssociations);
};
NSDebugMLLog(@"gswdync",@"_otherQueryAssociations=%@",_otherQueryAssociations);
ASSIGN(_otherAssociations,tmpOtherAssociations);
NSDebugMLLog(@"gswdync",@"_otherAssociations=%@",_otherAssociations);
//TODO NSDictionary* otherQueryAssociations;
if (!_action
&& !_href
&& !_pageName
&& !_directActionName
&& !_actionClass
&& !_redirectURL
&& !_filename
&& !_data)
{
NSString* parametersList=@"'action' or 'href' or 'pageName' or 'directActionName' or 'actionClass'";
if (!WOStrictFlag)
parametersList=[parametersList stringByAppendingFormat:@"'redirectURL' or 'filename' or 'data'"];
ExceptionRaise(@"GSWHyperlink",
@"You need to specify at least %@ parameter",
parametersList);
};
if ([_action isValueConstant])
{
ExceptionRaise0(@"GSWHyperlink",
@"'action' parameter can't be a constant");
};
if ((self=[super initWithName:aName
associations:nil
@ -180,6 +216,7 @@ static char rcsId[] = "$Id$";
DESTROY(_href);
DESTROY(_disabled);
DESTROY(_fragmentIdentifier);
DESTROY(_secure);
DESTROY(_queryDictionary);
DESTROY(_actionClass);
DESTROY(_directActionName);
@ -224,6 +261,8 @@ static char rcsId[] = "$Id$";
int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb];
#endif
LOGObjectFnStart();
NS_DURING
{
GSWStartElement(context);
GSWSaveAppendToResponseElementID(context);
if (_disabled)
@ -244,21 +283,8 @@ static char rcsId[] = "$Id$";
[response _appendContentAsciiString:@"href"];
[response appendContentCharacter:'='];
[response appendContentCharacter:'"'];
if (_directActionName)
{
//OK
[self _appendCGIActionURLToResponse:response
inContext:context];
}
else if (_action || _pageName || _redirectURL)
{
NSString* anUrl=(NSString*)[context componentActionURL];
NSDebugMLLog(@"gswdync",@"anUrl=%@",anUrl);
[response appendContentString:anUrl];
[self _appendQueryStringToResponse:response
inContext:context];
}
else if (_href)
if (_href)
{
NSString* hrefValue=[self hrefInContext:context];
[response appendContentString:hrefValue];
@ -268,6 +294,36 @@ static char rcsId[] = "$Id$";
};
NSDebugMLLog(@"gswdync",@"href=%@",_href);
NSDebugMLLog(@"gswdync",@"hrefValue=%@",hrefValue);
[self _appendQueryStringToResponse:response
inContext:context];
[self _appendFragmentToResponse:response
inContext:context];
}
else if (_actionClass || _directActionName)
{
//OK
[self _appendCGIActionURLToResponse:response
inContext:context];
}
else if (_action || _pageName || _redirectURL)
{
//OK
NSString* anUrl=nil;
BOOL completeUrlsPreviousState=NO;
BOOL isSecure=[self evaluateCondition:_secure
inContext:context];
// Force complete URLs
if (isSecure)
completeUrlsPreviousState=[context _generateCompleteURLs];
anUrl=(NSString*)[context componentActionURLIsSecure:isSecure];
NSDebugMLLog(@"gswdync",@"anUrl=%@",anUrl);
[response appendContentString:anUrl];
[self _appendQueryStringToResponse:response
inContext:context];
[self _appendFragmentToResponse:response
inContext:context];
if (isSecure && !completeUrlsPreviousState)
[context _generateRelativeURLs];
}
else if (!WOStrictFlag && (_filename || _data))
{
@ -326,7 +382,10 @@ static char rcsId[] = "$Id$";
}
else
{
LOGObjectFnNotImplemented(); //TODOFN
[self _appendQueryStringToResponse:response
inContext:context];
[self _appendFragmentToResponse:response
inContext:context];
};
[response appendContentCharacter:'"'];
NSDebugMLLog(@"gswdync",@"otherAssociations=%@",_otherAssociations);
@ -361,6 +420,7 @@ static char rcsId[] = "$Id$";
if (stringValue)
[response appendContentHTMLString:stringValue];
};
NSDebugMLLog(@"gswdync",@"_children=%p",_children);
if (_children)
{
[context appendZeroElementIDComponent];
@ -377,6 +437,17 @@ static char rcsId[] = "$Id$";
#ifndef NDEBBUG
NSAssert(elementsNb==[(GSWElementIDString*)[context elementID]elementsNb],@"GSWHyperlink appendToResponse: bad elementID");
#endif
}
NS_HANDLER
{
LOGException0(@"exception in GSWHyperlink appendToResponse:inContext");
LOGException(@"exception=%@",localException);
localException=ExceptionByAddingUserInfoObjectFrameInfo(localException,
@"In GSWForm appendToResponse:inContext");
LOGException(@"exception=%@",localException);
[localException raise];
}
NS_ENDHANDLER;
LOGObjectFnStop();
};
@ -403,54 +474,47 @@ static char rcsId[] = "$Id$";
NSString* actionString=nil;
NSDictionary* queryDictionary=nil;
NSString* anUrl=nil;
BOOL completeUrlsPreviousState=NO;
BOOL isSecure=NO;
LOGObjectFnStart();
actionString=[self computeActionStringInContext:context];
NSDebugMLLog(@"gswdync",@"actionString=%@",actionString);
queryDictionary=[self computeQueryDictionaryInContext:context];
NSDebugMLLog(@"gswdync",@"queryDictionary=%@",queryDictionary);
isSecure=[self evaluateCondition:_secure
inContext:context];
// Force complete URLs
if (isSecure)
completeUrlsPreviousState=[context _generateCompleteURLs];
anUrl=(NSString*)[context directActionURLForActionNamed:actionString
queryDictionary:queryDictionary];
queryDictionary:queryDictionary
isSecure:isSecure];
NSDebugMLLog(@"gswdync",@"anUrl=%@",anUrl);
if (isSecure && !completeUrlsPreviousState)
[context _generateRelativeURLs];
[response appendContentString:anUrl];
[self _appendFragmentToResponse:response
inContext:context];
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(id)computeActionStringInContext:(GSWContext*)context
-(NSString*)computeActionStringInContext:(GSWContext*)context
{
//OK
GSWComponent* component=nil;
id tmpDirectActionString=nil;
id directActionNameValue=nil;
id actionClassValue=nil;
NSString* actionString=nil;
LOGObjectFnStart();
component=[context component];
if (_directActionName)
directActionNameValue=[_directActionName valueInComponent:component];
if (_actionClass)
actionClassValue=[_actionClass valueInComponent:component];
if (actionClassValue)
{
if (directActionNameValue)
tmpDirectActionString=[NSString stringWithFormat:@"%@/%@",
actionClassValue,
directActionNameValue];
else
tmpDirectActionString=actionClassValue;
}
else if (directActionNameValue)
tmpDirectActionString=directActionNameValue;
else
{
LOGSeriousError(@"No actionClass (for %@) and no directActionName (for %@)",
actionClass,
directActionName);
};
NSDebugMLLog(@"gswdync",@"tmpDirectActionString=%@",tmpDirectActionString);
actionString=[self computeActionStringWithActionClassAssociation:_actionClass
directActionNameAssociation:_directActionName
inContext:context];
LOGObjectFnStop();
return tmpDirectActionString;
return actionString;
};
//--------------------------------------------------------------------
@ -492,66 +556,37 @@ static char rcsId[] = "$Id$";
//--------------------------------------------------------------------
-(NSDictionary*)computeQueryDictionaryInContext:(GSWContext*)context
{
//OK
NSMutableDictionary* queryDictionary=nil;
GSWComponent* component=nil;
GSWSession* session=nil;
NSDictionary* queryDictionary=nil;
LOGObjectFnStart();
queryDictionary=(NSMutableDictionary*)[NSMutableDictionary dictionary];
component=[context component];
session=[context existingSession];
if (session)
{
if (!_action && !_pageName
&& (WOStrictFlag || (!WOStrictFlag && !_redirectURL))) //??
{
NSString* sessionID=[session sessionID];
[queryDictionary setObject:sessionID
forKey:GSWKey_SessionID[GSWebNamingConv]];
};
};
//TODOV
if (_otherQueryAssociations)
{
NSEnumerator *enumerator = [_otherQueryAssociations keyEnumerator];
id oaKey=nil;
while ((oaKey = [enumerator nextObject]))
{
id oaValue=[[_otherQueryAssociations objectForKey:oaKey] valueInComponent:component];
if (!oaValue)
oaValue=[NSString string];
[queryDictionary setObject:oaValue
forKey:oaKey];
};
};
if (_queryDictionary)
{
NSEnumerator *enumerator = nil;
NSDictionary* queryDictionaryValue=[_queryDictionary valueInComponent:component];
id oaKey;
NSAssert3(!queryDictionaryValue || [queryDictionaryValue isKindOfClass:[NSDictionary class]],
@"queryDictionary value is not a dictionary but a %@. association was: %@. queryDictionaryValue is:",
[queryDictionaryValue class],
_queryDictionary,
queryDictionaryValue);
enumerator = [queryDictionaryValue keyEnumerator];
while ((oaKey = [enumerator nextObject]))
{
id oaValue=[queryDictionaryValue objectForKey:oaKey];
if (!oaValue)
oaValue=@"";
[queryDictionary setObject:oaValue
forKey:oaKey];
};
};
//TODO finished ??
queryDictionary=[self computeQueryDictionaryWithActionClassAssociation:_actionClass
directActionNameAssociation:_directActionName
queryDictionaryAssociation:_queryDictionary
otherQueryAssociations:_otherQueryAssociations
inContext:context];
LOGObjectFnStop();
return queryDictionary;
};
//--------------------------------------------------------------------
-(void)_appendFragmentToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
{
//OK
LOGObjectFnStart();
NSDebugMLLog(@"gswdync",@"_fragmentIdentifier=%@",_fragmentIdentifier);
if (_fragmentIdentifier)
{
id fragment=[_fragmentIdentifier valueInComponent:[context component]];
NSDebugMLLog(@"gswdync",@"fragment=%@",fragment);
if (fragment)
{
[response appendContentCharacter:'#'];
[response appendContentString:fragment];
};
};
LOGObjectFnStop();
};
//--------------------------------------------------------------------
//NDFN
-(NSString*)hrefInContext:(GSWContext*)context

View file

@ -1,6 +1,6 @@
/** GSWImage.h - <title>GSWeb: Class GSWImage</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
@ -34,7 +34,10 @@
@interface GSWImage: GSWHTMLURLValuedElement
{
GSWAssociation* _width;
GSWAssociation* _height;
}
-(id)initWithName:(NSString*)name
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements;

View file

@ -1,12 +1,13 @@
/** GSWImage.m - <title>GSWeb: Class GSWImage</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
$Revision$
$Date$
$Id$
This file is part of the GNUstep Web Library.
@ -27,7 +28,7 @@
</license>
**/
static char rcsId[] = "$Id$";
static const char rcsId[]="$Id$";
#include <GSWeb/GSWeb.h>
@ -36,9 +37,25 @@ static char rcsId[] = "$Id$";
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)name
associations:(NSDictionary*)associations
associations:(NSDictionary*)inAssociations
contentElements:(NSArray*)elements
{
NSMutableDictionary* associations=nil;
LOGObjectFnStartC("GSWImage");
associations=[NSMutableDictionary dictionaryWithDictionary:inAssociations];
_width = [[inAssociations objectForKey:width__Key
withDefaultObject:[_width autorelease]] retain];
NSDebugMLLog(@"gswdync",@"width=%@",_width);
_height = [[inAssociations objectForKey:height__Key
withDefaultObject:[_height autorelease]] retain];
NSDebugMLLog(@"gswdync",@"height=%@",_height);
[associations removeObjectForKey:width__Key];
[associations removeObjectForKey:height__Key];
if ((self=[super initWithName:name
associations:associations
contentElements:elements]))
@ -50,6 +67,8 @@ static char rcsId[] = "$Id$";
//--------------------------------------------------------------------
-(void)dealloc
{
DESTROY(_width);
DESTROY(_height);
[super dealloc];
};
@ -80,4 +99,39 @@ static char rcsId[] = "$Id$";
};
//--------------------------------------------------------------------
+(BOOL)hasGSWebObjectsAssociations
{
return YES;
};
//--------------------------------------------------------------------
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
{
//OK
GSWComponent* component=nil;
LOGObjectFnStartC("GSWImage");
[super appendGSWebObjectsAssociationsToResponse:response
inContext:context];
if (_width || _height)
{
if (_width)
{
id width=[_width valueInComponent:component];
[response _appendContentAsciiString:@" width=\""];
[response appendContentHTMLString:width];
[response appendContentCharacter:'"'];
};
if (_height)
{
id height=[_height valueInComponent:component];
[response _appendContentAsciiString:@" height=\""];
[response appendContentHTMLString:height];
[response appendContentCharacter:'"'];
};
};
LOGObjectFnStopC("GSWImage");
};
@end

View file

@ -2,7 +2,7 @@
#define INC_GSWPageDefLexer_h_
/*
* ANTLR-generated file resulting from grammar PageDef.g
* ANTLR-generated file resulting from grammar /tmp/PageDef.g
*
* Terence Parr, MageLang Institute
* with John Lilley, Empathy Software
@ -38,6 +38,7 @@
/*public: */-(void) mSTRINGWithCreateToken:(BOOL)_createToken ;
/*public: */-(void) mIDENTREFWithCreateToken:(BOOL)_createToken ;
/*public: */-(void) mPIDENTREFWithCreateToken:(BOOL)_createToken ;
/*public: */-(void) mINTWithCreateToken:(BOOL)_createToken ;
/*public: */-(void) mYESWithCreateToken:(BOOL)_createToken ;
/*public: */-(void) mNOWithCreateToken:(BOOL)_createToken ;
/*public: */-(void) mLCURLYWithCreateToken:(BOOL)_createToken ;
@ -47,9 +48,9 @@
/*public: */-(void) mTILDEWithCreateToken:(BOOL)_createToken ;
/*public: */-(void) mCOLUMNWithCreateToken:(BOOL)_createToken ;
/*public: */-(void) mASSIGNWithCreateToken:(BOOL)_createToken ;
/*public: */-(void) mQUESTIONMARKWithCreateToken:(BOOL)_createToken ;
/*public: */-(void) mWSWithCreateToken:(BOOL)_createToken ;
/*protected: */-(void) mESCWithCreateToken:(BOOL)_createToken ;
/*public: */-(void) mINTWithCreateToken:(BOOL)_createToken ;
/*public: */-(void) mHEXNUMWithCreateToken:(BOOL)_createToken ;
/*protected: */-(void) mHEXINTWithCreateToken:(BOOL)_createToken ;
/*protected: */-(void) mHEXDIGITWithCreateToken:(BOOL)_createToken ;

View file

@ -1,5 +1,5 @@
/*
* ANTLR-generated file resulting from grammar PageDef.g
* ANTLR-generated file resulting from grammar /tmp/PageDef.g
*
* Terence Parr, MageLang Institute
* with John Lilley, Empathy Software
@ -67,6 +67,14 @@
_rettoken=_returnToken;
break;
}
case ((unichar)('0')): case ((unichar)('1')): case ((unichar)('2')): case ((unichar)('3')):
case ((unichar)('4')): case ((unichar)('5')): case ((unichar)('6')): case ((unichar)('7')):
case ((unichar)('8')): case ((unichar)('9')):
{
[self mINTWithCreateToken:YES];
_rettoken=_returnToken;
break;
}
case ((unichar)('{')):
{
[self mLCURLYWithCreateToken:YES];
@ -109,17 +117,15 @@
_rettoken=_returnToken;
break;
}
case ((unichar)('\t')): case ((unichar)('\n')): case ((unichar)('\r')): case ((unichar)(' ')):
case ((unichar)('?')):
{
[self mWSWithCreateToken:YES];
[self mQUESTIONMARKWithCreateToken:YES];
_rettoken=_returnToken;
break;
}
case ((unichar)('0')): case ((unichar)('1')): case ((unichar)('2')): case ((unichar)('3')):
case ((unichar)('4')): case ((unichar)('5')): case ((unichar)('6')): case ((unichar)('7')):
case ((unichar)('8')): case ((unichar)('9')):
case ((unichar)('\t')): case ((unichar)('\n')): case ((unichar)('\r')): case ((unichar)(' ')):
{
[self mINTWithCreateToken:YES];
[self mWSWithCreateToken:YES];
_rettoken=_returnToken;
break;
}
@ -224,11 +230,11 @@ int _begin=[text length];
}
else
{
goto _loop32;
goto _loop35;
}
} while (YES);
_loop32:;
_loop35:;
}
{
switch ( [self LA:1])
@ -376,11 +382,11 @@ int _begin=[text length];
}
else
{
goto _loop38;
goto _loop41;
}
}
} while (YES);
_loop38:;
_loop41:;
}
[self matchString:@"*/"];
_ttype = ANTLRToken_SKIP;
@ -486,11 +492,11 @@ int _begin=[text length];
}
default:
{
goto _loop43;
goto _loop46;
}
}
} while (YES);
_loop43:;
_loop46:;
}
_ttype = [self testLiteralsTable:_ttype];
if ( _createToken && _token==0 )
@ -729,11 +735,11 @@ int _begin=[text length];
}
default:
{
goto _loop66;
goto _loop70;
}
}
} while (YES);
_loop66:;
_loop70:;
}
[self matchCharacter:'\''];
break;
@ -822,11 +828,11 @@ int _begin=[text length];
}
default:
{
goto _loop69;
goto _loop73;
}
}
} while (YES);
_loop69:;
_loop73:;
}
[self matchCharacter:'"'];
break;
@ -925,11 +931,11 @@ int _begin=[text length];
}
default:
{
goto _loop49;
goto _loop52;
}
}
} while (YES);
_loop49:;
_loop52:;
}
_ttype = [self testLiteralsTable:_ttype];
if ( _createToken && _token==0 )
@ -971,6 +977,13 @@ int _begin=[text length];
[self mIDENTREFWithCreateToken:NO];
break;
}
case ((unichar)('0')): case ((unichar)('1')): case ((unichar)('2')): case ((unichar)('3')):
case ((unichar)('4')): case ((unichar)('5')): case ((unichar)('6')): case ((unichar)('7')):
case ((unichar)('8')): case ((unichar)('9')):
{
[self mINTWithCreateToken:NO];
break;
}
case ((unichar)('"')): case ((unichar)('\'')):
{
[self mSTRINGWithCreateToken:NO];
@ -992,6 +1005,40 @@ int _begin=[text length];
//LOGObjectFnStop();
}
-(void) mINTWithCreateToken:(BOOL)_createToken
{
ANTLRDefToken _token=nil;
int _begin=[text length];
ANTLRTokenType _ttype = GSWPageDefParserTokenType_INT;
int _saveIndex;
//LOGObjectFnStart();
{
int _cnt77=0;
do
{
if ((([self LA:1] >= ((unichar)('0')) && [self LA:1] <= ((unichar)('9')))))
{
[self mDIGITWithCreateToken:NO];
}
else
{
if ( _cnt77>=1 ) { goto _loop77; } else {[ANTLRScannerException raiseWithReason:[NSString stringWithFormat:@"no viable alt for char: %@",[ANTLRCharScanner charName:[self LA:1]]] line:[self line]];}
}
_cnt77++;
} while (YES);
_loop77:;
}
if ( _createToken && _token==0 )
{
_token = [self makeToken:_ttype];
[_token setText:[text substringFromIndex:_begin]];
}
ASSIGN(_returnToken,_token);
//LOGObjectFnStop();
}
-(void) mYESWithCreateToken:(BOOL)_createToken
{
ANTLRDefToken _token=nil;
@ -1156,6 +1203,24 @@ int _begin=[text length];
//LOGObjectFnStop();
}
-(void) mQUESTIONMARKWithCreateToken:(BOOL)_createToken
{
ANTLRDefToken _token=nil;
int _begin=[text length];
ANTLRTokenType _ttype = GSWPageDefParserTokenType_QUESTIONMARK;
int _saveIndex;
//LOGObjectFnStart();
[self matchCharacter:'?'];
if ( _createToken && _token==0 )
{
_token = [self makeToken:_ttype];
[_token setText:[text substringFromIndex:_begin]];
}
ASSIGN(_returnToken,_token);
//LOGObjectFnStop();
}
-(void) mWSWithCreateToken:(BOOL)_createToken
{
ANTLRDefToken _token=nil;
@ -1265,7 +1330,7 @@ int _begin=[text length];
case ((unichar)('u')):
{
{
int _cnt78=0;
int _cnt82=0;
do
{
if (([self LA:1]==((unichar)('u'))))
@ -1274,12 +1339,12 @@ int _begin=[text length];
}
else
{
if ( _cnt78>=1 ) { goto _loop78; } else {[ANTLRScannerException raiseWithReason:[NSString stringWithFormat:@"no viable alt for char: %@",[ANTLRCharScanner charName:[self LA:1]]] line:[self line]];}
if ( _cnt82>=1 ) { goto _loop82; } else {[ANTLRScannerException raiseWithReason:[NSString stringWithFormat:@"no viable alt for char: %@",[ANTLRCharScanner charName:[self LA:1]]] line:[self line]];}
}
_cnt78++;
_cnt82++;
} while (YES);
_loop78:;
_loop82:;
}
[self mHEXDIGITWithCreateToken:NO];
[self mHEXDIGITWithCreateToken:NO];
@ -1362,40 +1427,6 @@ int _begin=[text length];
//LOGObjectFnStop();
}
-(void) mINTWithCreateToken:(BOOL)_createToken
{
ANTLRDefToken _token=nil;
int _begin=[text length];
ANTLRTokenType _ttype = GSWPageDefParserTokenType_INT;
int _saveIndex;
//LOGObjectFnStart();
{
int _cnt73=0;
do
{
if ((([self LA:1] >= ((unichar)('0')) && [self LA:1] <= ((unichar)('9')))))
{
[self mDIGITWithCreateToken:NO];
}
else
{
if ( _cnt73>=1 ) { goto _loop73; } else {[ANTLRScannerException raiseWithReason:[NSString stringWithFormat:@"no viable alt for char: %@",[ANTLRCharScanner charName:[self LA:1]]] line:[self line]];}
}
_cnt73++;
} while (YES);
_loop73:;
}
if ( _createToken && _token==0 )
{
_token = [self makeToken:_ttype];
[_token setText:[text substringFromIndex:_begin]];
}
ASSIGN(_returnToken,_token);
//LOGObjectFnStop();
}
-(void) mHEXNUMWithCreateToken:(BOOL)_createToken
{
ANTLRDefToken _token=nil;
@ -1424,7 +1455,7 @@ int _begin=[text length];
//LOGObjectFnStart();
{
int _cnt88=0;
int _cnt92=0;
do
{
if (([GSWPageDefLexer___tokenSet_2 isMember:[self LA:1]]))
@ -1433,12 +1464,12 @@ int _begin=[text length];
}
else
{
if ( _cnt88>=1 ) { goto _loop88; } else {[ANTLRScannerException raiseWithReason:[NSString stringWithFormat:@"no viable alt for char: %@",[ANTLRCharScanner charName:[self LA:1]]] line:[self line]];}
if ( _cnt92>=1 ) { goto _loop92; } else {[ANTLRScannerException raiseWithReason:[NSString stringWithFormat:@"no viable alt for char: %@",[ANTLRCharScanner charName:[self LA:1]]] line:[self line]];}
}
_cnt88++;
_cnt92++;
} while (YES);
_loop88:;
_loop92:;
}
if ( _createToken && _token==0 )
{
@ -1515,7 +1546,7 @@ int _begin=[text length];
CONST unsigned long GSWPageDefLexer___tokenSet_0_data_[] = { 0UL, 132UL, 2281701374UL, 134217726UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL };
static ANTLRBitSet* GSWPageDefLexer___tokenSet_0=nil;
CONST unsigned long GSWPageDefLexer___tokenSet_1_data_[] = { 0UL, 132UL, 2281701375UL, 134217726UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL };
CONST unsigned long GSWPageDefLexer___tokenSet_1_data_[] = { 0UL, 67043460UL, 2281701375UL, 134217726UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL };
static ANTLRBitSet* GSWPageDefLexer___tokenSet_1=nil;
CONST unsigned long GSWPageDefLexer___tokenSet_2_data_[] = { 0UL, 67043328UL, 126UL, 126UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL };
static ANTLRBitSet* GSWPageDefLexer___tokenSet_2=nil;

View file

@ -2,7 +2,7 @@
#define INC_GSWPageDefParser_h_
/*
* ANTLR-generated file resulting from grammar PageDef.g
* ANTLR-generated file resulting from grammar /tmp/PageDef.g
*
* Terence Parr, MageLang Institute
* with John Lilley, Empathy Software
@ -41,6 +41,7 @@
/*public: */-(void) definition;
/*public: */-(void) classname;
/*public: */-(void) member;
/*public: */-(void) mname;
/*public: */-(void) mvalue;
/*public: */-(void) idref;
@end;
@ -58,5 +59,7 @@ extern CONST unsigned long GSWPageDefParser___tokenSet_3_data_[];
extern ANTLRBitSet* GSWPageDefParser___tokenSet_3;
extern CONST unsigned long GSWPageDefParser___tokenSet_4_data_[];
extern ANTLRBitSet* GSWPageDefParser___tokenSet_4;
extern CONST unsigned long GSWPageDefParser___tokenSet_5_data_[];
extern ANTLRBitSet* GSWPageDefParser___tokenSet_5;
#endif /*INC_GSWPageDefParser_h_*/

View file

@ -1,5 +1,5 @@
/*
* ANTLR-generated file resulting from grammar PageDef.g
* ANTLR-generated file resulting from grammar /tmp/PageDef.g
*
* Terence Parr, MageLang Institute
* with John Lilley, Empathy Software
@ -242,7 +242,7 @@
{
do
{
if (([self LA:1]==GSWPageDefParserTokenType_IDENT))
if (([self LA:1]==GSWPageDefParserTokenType_IDENT||[self LA:1]==GSWPageDefParserTokenType_QUESTIONMARK))
{
[self member];
[astFactory addASTChild:returnAST in:currentAST];
@ -336,20 +336,16 @@
ANTLRASTPair* currentAST=[[ANTLRASTPair new] autorelease];
ANTLRDefAST member_AST = ANTLRnullAST;
ANTLRDefToken memberName = nil;
ANTLRDefAST memberName_AST = ANTLRnullAST;
//LOGObjectFnStart();
ASSIGN(returnAST,ANTLRnullAST);
NS_DURING // for error handling
{
memberName = [self LT:1];
{
memberName_AST = [astFactory create:memberName];
[astFactory makeASTRoot:memberName_AST in:currentAST];
}
[self matchTokenType:GSWPageDefParserTokenType_IDENT];
ASSIGN(currentMemberName,[memberName text]);
[self mname];
memberName_AST = returnAST;
[astFactory addASTChild:returnAST in:currentAST];
ASSIGN(currentMemberName,([memberName_AST toStringListWithSiblingSeparator:@"" openSeparator:@"" closeSeparator:@""]));
{
ANTLRDefAST tmp7_AST = ANTLRnullAST;
tmp7_AST = [astFactory create:[self LT:1]];
@ -393,6 +389,60 @@
//LOGObjectFnStop();
}
-(void) mname
{
ANTLRASTPair* currentAST=[[ANTLRASTPair new] autorelease];
ANTLRDefAST mname_AST = ANTLRnullAST;
//LOGObjectFnStart();
ASSIGN(returnAST,ANTLRnullAST);
NS_DURING // for error handling
{
{
switch ( [self LA:1])
{
case GSWPageDefParserTokenType_QUESTIONMARK:
{
{
ANTLRDefAST tmp9_AST = ANTLRnullAST;
tmp9_AST = [astFactory create:[self LT:1]];
[astFactory addASTChild:tmp9_AST in:currentAST];
}
[self matchTokenType:GSWPageDefParserTokenType_QUESTIONMARK];
break;
}
case GSWPageDefParserTokenType_IDENT:
{
break;
}
default:
{
[ANTLRNoViableAltException raiseWithToken:[self LT:1]];
}
}
}
{
{
ANTLRDefAST tmp10_AST = ANTLRnullAST;
tmp10_AST = [astFactory create:[self LT:1]];
[astFactory addASTChild:tmp10_AST in:currentAST];
}
[self matchTokenType:GSWPageDefParserTokenType_IDENT];
}
mname_AST = [currentAST root];
}
NS_HANDLER
{
[self reportErrorWithException:localException];
[self consume];
[self consumeUntilTokenBitSet:GSWPageDefParser___tokenSet_4];
}
NS_ENDHANDLER;
ASSIGN(returnAST,mname_AST);
//LOGObjectFnStop();
}
-(void) mvalue
{
@ -440,9 +490,9 @@
case GSWPageDefParserTokenType_YES:
{
{
ANTLRDefAST tmp9_AST = ANTLRnullAST;
tmp9_AST = [astFactory create:[self LT:1]];
[astFactory addASTChild:tmp9_AST in:currentAST];
ANTLRDefAST tmp11_AST = ANTLRnullAST;
tmp11_AST = [astFactory create:[self LT:1]];
[astFactory addASTChild:tmp11_AST in:currentAST];
}
[self matchTokenType:GSWPageDefParserTokenType_YES];
{ GSWAssociation* assoc=[GSWAssociation associationWithValue:[NSNumber numberWithBool:YES]];
@ -452,9 +502,9 @@
case GSWPageDefParserTokenType_NO:
{
{
ANTLRDefAST tmp10_AST = ANTLRnullAST;
tmp10_AST = [astFactory create:[self LT:1]];
[astFactory addASTChild:tmp10_AST in:currentAST];
ANTLRDefAST tmp12_AST = ANTLRnullAST;
tmp12_AST = [astFactory create:[self LT:1]];
[astFactory addASTChild:tmp12_AST in:currentAST];
}
[self matchTokenType:GSWPageDefParserTokenType_NO];
{ GSWAssociation* assoc=[GSWAssociation associationWithValue:[NSNumber numberWithBool:NO]];
@ -497,7 +547,7 @@
{
[self reportErrorWithException:localException];
[self consume];
[self consumeUntilTokenBitSet:GSWPageDefParser___tokenSet_4];
[self consumeUntilTokenBitSet:GSWPageDefParser___tokenSet_5];
}
NS_ENDHANDLER;
ASSIGN(returnAST,mvalue_AST);
@ -520,9 +570,9 @@
case GSWPageDefParserTokenType_CIRC:
{
{
ANTLRDefAST tmp11_AST = ANTLRnullAST;
tmp11_AST = [astFactory create:[self LT:1]];
[astFactory addASTChild:tmp11_AST in:currentAST];
ANTLRDefAST tmp13_AST = ANTLRnullAST;
tmp13_AST = [astFactory create:[self LT:1]];
[astFactory addASTChild:tmp13_AST in:currentAST];
}
[self matchTokenType:GSWPageDefParserTokenType_CIRC];
break;
@ -530,9 +580,9 @@
case GSWPageDefParserTokenType_TILDE:
{
{
ANTLRDefAST tmp12_AST = ANTLRnullAST;
tmp12_AST = [astFactory create:[self LT:1]];
[astFactory addASTChild:tmp12_AST in:currentAST];
ANTLRDefAST tmp14_AST = ANTLRnullAST;
tmp14_AST = [astFactory create:[self LT:1]];
[astFactory addASTChild:tmp14_AST in:currentAST];
}
[self matchTokenType:GSWPageDefParserTokenType_TILDE];
break;
@ -554,9 +604,9 @@
case GSWPageDefParserTokenType_IDENT:
{
{
ANTLRDefAST tmp13_AST = ANTLRnullAST;
tmp13_AST = [astFactory create:[self LT:1]];
[astFactory addASTChild:tmp13_AST in:currentAST];
ANTLRDefAST tmp15_AST = ANTLRnullAST;
tmp15_AST = [astFactory create:[self LT:1]];
[astFactory addASTChild:tmp15_AST in:currentAST];
}
[self matchTokenType:GSWPageDefParserTokenType_IDENT];
break;
@ -564,9 +614,9 @@
case GSWPageDefParserTokenType_IDENTREF:
{
{
ANTLRDefAST tmp14_AST = ANTLRnullAST;
tmp14_AST = [astFactory create:[self LT:1]];
[astFactory addASTChild:tmp14_AST in:currentAST];
ANTLRDefAST tmp16_AST = ANTLRnullAST;
tmp16_AST = [astFactory create:[self LT:1]];
[astFactory addASTChild:tmp16_AST in:currentAST];
}
[self matchTokenType:GSWPageDefParserTokenType_IDENTREF];
break;
@ -585,9 +635,9 @@
case GSWPageDefParserTokenType_PIDENT:
{
{
ANTLRDefAST tmp15_AST = ANTLRnullAST;
tmp15_AST = [astFactory create:[self LT:1]];
[astFactory addASTChild:tmp15_AST in:currentAST];
ANTLRDefAST tmp17_AST = ANTLRnullAST;
tmp17_AST = [astFactory create:[self LT:1]];
[astFactory addASTChild:tmp17_AST in:currentAST];
}
[self matchTokenType:GSWPageDefParserTokenType_PIDENT];
break;
@ -595,20 +645,20 @@
case GSWPageDefParserTokenType_PIDENTREF:
{
{
ANTLRDefAST tmp16_AST = ANTLRnullAST;
tmp16_AST = [astFactory create:[self LT:1]];
[astFactory addASTChild:tmp16_AST in:currentAST];
ANTLRDefAST tmp18_AST = ANTLRnullAST;
tmp18_AST = [astFactory create:[self LT:1]];
[astFactory addASTChild:tmp18_AST in:currentAST];
}
[self matchTokenType:GSWPageDefParserTokenType_PIDENTREF];
break;
}
default:
{
goto _loop28;
goto _loop31;
}
}
} while (YES);
_loop28:;
_loop31:;
}
idref_AST = [currentAST root];
}
@ -616,7 +666,7 @@
{
[self reportErrorWithException:localException];
[self consume];
[self consumeUntilTokenBitSet:GSWPageDefParser___tokenSet_4];
[self consumeUntilTokenBitSet:GSWPageDefParser___tokenSet_5];
}
NS_ENDHANDLER;
ASSIGN(returnAST,idref_AST);
@ -637,6 +687,7 @@ static CONST NSString* GSWPageDefParser___tokenNames[] = {
@"RCURLY",
@"SEMI",
@"ASSIGN",
@"QUESTIONMARK",
@"INT",
@"YES",
@"NO",
@ -664,10 +715,12 @@ CONST unsigned long GSWPageDefParser___tokenSet_1_data_[] = { 146UL, 0UL, 0UL, 0
static ANTLRBitSet* GSWPageDefParser___tokenSet_1=nil;
CONST unsigned long GSWPageDefParser___tokenSet_2_data_[] = { 512UL, 0UL, 0UL, 0UL };
static ANTLRBitSet* GSWPageDefParser___tokenSet_2=nil;
CONST unsigned long GSWPageDefParser___tokenSet_3_data_[] = { 1152UL, 0UL, 0UL, 0UL };
CONST unsigned long GSWPageDefParser___tokenSet_3_data_[] = { 9344UL, 0UL, 0UL, 0UL };
static ANTLRBitSet* GSWPageDefParser___tokenSet_3=nil;
CONST unsigned long GSWPageDefParser___tokenSet_4_data_[] = { 3200UL, 0UL, 0UL, 0UL };
CONST unsigned long GSWPageDefParser___tokenSet_4_data_[] = { 4096UL, 0UL, 0UL, 0UL };
static ANTLRBitSet* GSWPageDefParser___tokenSet_4=nil;
CONST unsigned long GSWPageDefParser___tokenSet_5_data_[] = { 11392UL, 0UL, 0UL, 0UL };
static ANTLRBitSet* GSWPageDefParser___tokenSet_5=nil;
+(void)initialize
{
if (!GSWPageDefParser___tokenSet_0)
@ -680,6 +733,8 @@ static ANTLRBitSet* GSWPageDefParser___tokenSet_4=nil;
GSWPageDefParser___tokenSet_3=[[ANTLRBitSet bitSetWithULongBits:GSWPageDefParser___tokenSet_3_data_ length:8] retain];
if (!GSWPageDefParser___tokenSet_4)
GSWPageDefParser___tokenSet_4=[[ANTLRBitSet bitSetWithULongBits:GSWPageDefParser___tokenSet_4_data_ length:8] retain];
if (!GSWPageDefParser___tokenSet_5)
GSWPageDefParser___tokenSet_5=[[ANTLRBitSet bitSetWithULongBits:GSWPageDefParser___tokenSet_5_data_ length:8] retain];
}
+(void)dealloc
{
@ -688,6 +743,7 @@ static ANTLRBitSet* GSWPageDefParser___tokenSet_4=nil;
DESTROY(GSWPageDefParser___tokenSet_2);
DESTROY(GSWPageDefParser___tokenSet_3);
DESTROY(GSWPageDefParser___tokenSet_4);
DESTROY(GSWPageDefParser___tokenSet_5);
[[self superclass] dealloc];
}
@end

View file

@ -2,7 +2,7 @@
#define INC_GSWPageDefParserTokenTypes_h_
/*
* ANTLR-generated file resulting from grammar PageDef.g
* ANTLR-generated file resulting from grammar /tmp/PageDef.g
*
* Terence Parr, MageLang Institute
* with John Lilley, Empathy Software
@ -25,23 +25,24 @@ enum GSWPageDefParserTokenTypes {
GSWPageDefParserTokenType_RCURLY = 10,
GSWPageDefParserTokenType_SEMI = 11,
GSWPageDefParserTokenType_ASSIGN = 12,
GSWPageDefParserTokenType_INT = 13,
GSWPageDefParserTokenType_YES = 14,
GSWPageDefParserTokenType_NO = 15,
GSWPageDefParserTokenType_HEXNUM = 16,
GSWPageDefParserTokenType_CIRC = 17,
GSWPageDefParserTokenType_TILDE = 18,
GSWPageDefParserTokenType_IDENTREF = 19,
GSWPageDefParserTokenType_PIDENT = 20,
GSWPageDefParserTokenType_PIDENTREF = 21,
GSWPageDefParserTokenType_SL_COMMENT = 22,
GSWPageDefParserTokenType_ML_COMMENT = 23,
GSWPageDefParserTokenType_POINT = 24,
GSWPageDefParserTokenType_ESC = 25,
GSWPageDefParserTokenType_HEXINT = 26,
GSWPageDefParserTokenType_DIGIT = 27,
GSWPageDefParserTokenType_HEXDIGIT = 28,
GSWPageDefParserTokenType_LCLETTER = 29,
GSWPageDefParserTokenType_LETTER = 30,
GSWPageDefParserTokenType_QUESTIONMARK = 13,
GSWPageDefParserTokenType_INT = 14,
GSWPageDefParserTokenType_YES = 15,
GSWPageDefParserTokenType_NO = 16,
GSWPageDefParserTokenType_HEXNUM = 17,
GSWPageDefParserTokenType_CIRC = 18,
GSWPageDefParserTokenType_TILDE = 19,
GSWPageDefParserTokenType_IDENTREF = 20,
GSWPageDefParserTokenType_PIDENT = 21,
GSWPageDefParserTokenType_PIDENTREF = 22,
GSWPageDefParserTokenType_SL_COMMENT = 23,
GSWPageDefParserTokenType_ML_COMMENT = 24,
GSWPageDefParserTokenType_POINT = 25,
GSWPageDefParserTokenType_ESC = 26,
GSWPageDefParserTokenType_HEXINT = 27,
GSWPageDefParserTokenType_DIGIT = 28,
GSWPageDefParserTokenType_HEXDIGIT = 29,
GSWPageDefParserTokenType_LCLETTER = 30,
GSWPageDefParserTokenType_LETTER = 31,
};
#endif /*INC_GSWPageDefParserTokenTypes_h_*/

View file

@ -8,21 +8,22 @@ LCURLY=9
RCURLY=10
SEMI=11
ASSIGN=12
INT=13
YES=14
NO=15
HEXNUM=16
CIRC=17
TILDE=18
IDENTREF=19
PIDENT=20
PIDENTREF=21
SL_COMMENT=22
ML_COMMENT=23
POINT=24
ESC=25
HEXINT=26
DIGIT=27
HEXDIGIT=28
LCLETTER=29
LETTER=30
QUESTIONMARK=13
INT=14
YES=15
NO=16
HEXNUM=17
CIRC=18
TILDE=19
IDENTREF=20
PIDENT=21
PIDENTREF=22
SL_COMMENT=23
ML_COMMENT=24
POINT=25
ESC=26
HEXINT=27
DIGIT=28
HEXDIGIT=29
LCLETTER=30
LETTER=31

View file

@ -1,6 +1,6 @@
/** GSWRequest.h - <title>GSWeb: Class GSWRequest</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
@ -46,7 +46,9 @@
NSStringEncoding _defaultFormValueEncoding;
NSStringEncoding _formValueEncoding;
NSDictionary* _formValues;
NSDictionary* _uriElements;
NSDictionary* _cookie;
BOOL _finishedParsingMultipartFormData;
NSString* _applicationURLPrefix;
NSArray* _requestHandlerPathArray;
NSArray* _browserLanguages;
@ -54,6 +56,7 @@
BOOL _isUsingWebServer;
BOOL _formValueEncodingDetectionEnabled;
int _applicationNumber;
GSWContext* _context;//Don't retain/release because request is retained by context
};
-(id)initWithMethod:(NSString*)aMethod
@ -66,6 +69,8 @@
-(void)dealloc;
-(id)copyWithZone:(NSZone*)zone;
-(GSWContext*)_context;
-(void)_setContext:(GSWContext*)context;
-(NSData*)content;
-(NSDictionary*)headers;
-(NSString*)headerForKey:(NSString*)key;
@ -103,6 +108,14 @@
-(NSDictionary*)formValues;
@end
//====================================================================
@interface GSWRequest (GSWURIElementReporting)
-(NSArray*)uriElementKeys;
-(NSString*)uriElementForKey:(NSString*)key;
-(NSDictionary*)uriElements;
@end
//====================================================================
@interface GSWRequest (GSWRequestTypeReporting)
-(BOOL)isFromClientComponent;
@ -125,6 +138,7 @@
//====================================================================
@interface GSWRequest (GSWRequestA)
-(NSString*)sessionIDFromValuesOrCookieByLookingForCookieFirst:(BOOL)lookCookieFirst;
-(NSString*)sessionID;
-(NSString*)requestHandlerPath;
-(NSString*)adaptorPrefix;
@ -164,6 +178,7 @@
-(GSWDynamicURLString*)_applicationURLPrefix;
-(NSDictionary*)_formValues;
-(void)_getFormValuesFromURLEncoding;
+(BOOL)_lookForIDsInCookiesFirst;
-(BOOL)_hasFormValues;
@end
@ -198,8 +213,9 @@
-(NSString*)contextID;
-(NSString*)senderID;
//NDFN
-(NSDictionary*)uriOrFormOrCookiesElementsByLookingForCookieFirst:(BOOL)lookCookieFirst;
-(NSMutableDictionary*)uriOrFormOrCookiesElements;
-(NSMutableDictionary*)uriElements;
-(NSMutableDictionary*)_uriElements;
@end
//====================================================================
@interface GSWRequest (GSWRequestL)

View file

@ -1,12 +1,13 @@
/** GSWRequest.m - <title>GSWeb: Class GSWRequest</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
$Revision$
$Date$
$Id$
This file is part of the GNUstep Web Library.
@ -27,10 +28,10 @@
</license>
**/
static char rcsId[] = "$Id$";
static const char rcsId[]="$Id$";
#include <GSWeb/GSWeb.h>
#include <Foundation/GSMime.h>
//====================================================================
@implementation GSWRequest
@ -102,6 +103,8 @@ static char rcsId[] = "$Id$";
DESTROY(_userInfo);
NSDebugFLog0(@"Release GSWRequest formValues");
DESTROY(_formValues);
NSDebugFLog0(@"Release GSWRequest uriElements");
DESTROY(_uriElements);
NSDebugFLog0(@"Release GSWRequest cookie");
DESTROY(_cookie);
NSDebugFLog0(@"Release GSWRequest applicationURLPrefix");
@ -129,6 +132,7 @@ static char rcsId[] = "$Id$";
clone->_defaultFormValueEncoding=_defaultFormValueEncoding;
clone->_formValueEncoding=_formValueEncoding;
ASSIGNCOPY(clone->_formValues,_formValues);
ASSIGNCOPY(clone->_uriElements,_uriElements);
ASSIGNCOPY(clone->_cookie,_cookie);
ASSIGNCOPY(clone->_applicationURLPrefix,_applicationURLPrefix);
ASSIGNCOPY(clone->_requestHandlerPathArray,_requestHandlerPathArray);
@ -141,6 +145,18 @@ static char rcsId[] = "$Id$";
return clone;
};
//--------------------------------------------------------------------
-(GSWContext*)_context
{
return _context;
}
//--------------------------------------------------------------------
-(void)_setContext:(GSWContext*)context
{
_context = context;//Don't retain because request is retained by context
}
//--------------------------------------------------------------------
// content
@ -370,7 +386,7 @@ static char rcsId[] = "$Id$";
-(NSString*)description
{
return [NSString stringWithFormat:@"<%s %p -
method=%@, uri=%@, httpVersion=%@, headers=%@, content=%@, userInfo=%@, defaultFormValueEncoding=%u, formValueEncoding=%u, formValues=%@, cookie=%@, applicationURLPrefix=%@, requestHandlerPathArray=%@, browserLanguages=%@, requestType=%d, isUsingWebServer=%s, formValueEncodingDetectionEnabled=%s, applicationNumber=%d",
method=%@, uri=%@, httpVersion=%@, headers=%@, content=%@, userInfo=%@, defaultFormValueEncoding=%u, formValueEncoding=%u, formValues=%@, uriElements=%@, cookie=%@, applicationURLPrefix=%@, requestHandlerPathArray=%@, browserLanguages=%@, requestType=%d, isUsingWebServer=%s, formValueEncodingDetectionEnabled=%s, applicationNumber=%d",
object_get_class_name(self),
(void*)self,
_method,
@ -382,6 +398,7 @@ method=%@, uri=%@, httpVersion=%@, headers=%@, content=%@, userInfo=%@, defaultF
_defaultFormValueEncoding,
_formValueEncoding,
_formValues,
_uriElements,
_cookie,
_applicationURLPrefix,
_requestHandlerPathArray,
@ -526,6 +543,81 @@ method=%@, uri=%@, httpVersion=%@, headers=%@, content=%@, userInfo=%@, defaultF
@end
//====================================================================
@implementation GSWRequest (GSWURIElementReporting)
//--------------------------------------------------------------------
// uriValueKeys
-(NSArray*)uriElementKeys
{
NSDictionary* uriElements=nil;
NSArray* uriElementKeys=nil;
LOGObjectFnStart();
NS_DURING
{
uriElements=[self _uriElements];
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
@"GSWRequest uriElementKeys");
LOGException(@"%@ (%@)",localException,[localException reason]);
[localException raise];
};
NS_ENDHANDLER;
uriElementKeys=[uriElements allKeys];
LOGObjectFnStop();
return uriElementKeys;
};
//--------------------------------------------------------------------
// uriElementForKey:
-(NSString*)uriElementForKey:(NSString*)key
{
NSArray* uriElement=nil;
NSDictionary* uriElements=nil;
LOGObjectFnStart();
NS_DURING
{
uriElements=[self _uriElements];
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,@"GSWRequest uriElementForKey:");
LOGException(@"%@ (%@)",localException,[localException reason]);
[localException raise];
};
NS_ENDHANDLER;
uriElement=[uriElements objectForKey:key];
LOGObjectFnStop();
return uriElement;
};
//--------------------------------------------------------------------
// uriElements
-(NSDictionary*)uriElements
{
NSDictionary* uriElements=nil;
LOGObjectFnStart();
NS_DURING
{
uriElements=[self _uriElements];
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
@"GSWRequest uriElements");
LOGException(@"%@ (%@)",localException,[localException reason]);
[localException raise];
};
NS_ENDHANDLER;
LOGObjectFnStop();
return uriElements;
};
@end
//====================================================================
@implementation GSWRequest (GSWRequestTypeReporting)
@ -709,21 +801,35 @@ method=%@, uri=%@, httpVersion=%@, headers=%@, content=%@, userInfo=%@, defaultF
//====================================================================
@implementation GSWRequest (GSWRequestA)
//--------------------------------------------------------------------
-(NSString*)sessionIDFromValuesOrCookie
{
return [self sessionIDFromValuesOrCookieByLookingForCookieFirst:[[self class]_lookForIDsInCookiesFirst]];
};
//--------------------------------------------------------------------
-(NSString*)sessionIDFromValuesOrCookieByLookingForCookieFirst:(BOOL)lookCookieFirst
{
NSString* sessionID=nil;
LOGObjectFnStart();
sessionID=[self uriOrFormOrCookiesElementForKey:GSWKey_SessionID[GSWebNamingConv]
byLookingForCookieFirst:lookCookieFirst];
if (!sessionID)
{
sessionID=[self uriOrFormOrCookiesElementForKey:GSWKey_SessionID[GSWebNamingConvInversed]
byLookingForCookieFirst:lookCookieFirst];
};
LOGObjectFnStop();
return sessionID;
};
//--------------------------------------------------------------------
// sessionID
// nil if first request of session
-(NSString*)sessionID
{
NSString* sessionID=nil;
NSDictionary* uriElements=nil;
LOGObjectFnStart();
uriElements=[self uriOrFormOrCookiesElements];
sessionID=[uriElements objectForKey:GSWKey_SessionID[GSWebNamingConv]];
if (!sessionID)
sessionID=[uriElements objectForKey:GSWKey_SessionID[GSWebNamingConvInversed]];
LOGObjectFnStop();
return sessionID;
return [self sessionIDFromValuesOrCookie];
};
//--------------------------------------------------------------------
@ -888,20 +994,10 @@ method=%@, uri=%@, httpVersion=%@, headers=%@, content=%@, userInfo=%@, defaultF
{
//OK
NSString* urlQueryString=nil;
// NSArray* url=nil;
LOGObjectFnStart();
NSDebugMLLog(@"requests",@"uri=%@",_uri);
NSDebugMLLog(@"requests",@"uri class=%@",[_uri class]);
urlQueryString=[_uri urlQueryString];
/*
url=[_uri componentsSeparatedByString:@"?"];
NSDebugMLLog(@"requests",@"url=%@",url);
if ([url count]>1)
urlQueryString=[[url subarrayWithRange:NSMakeRange(1,[url count])]
componentsJoinedByString:@"?"];
else
urlQueryString=[NSString string];
*/
LOGObjectFnStop();
return urlQueryString;
};
@ -1001,7 +1097,7 @@ method=%@, uri=%@, httpVersion=%@, headers=%@, content=%@, userInfo=%@, defaultF
{
//OK
LOGObjectFnStart();
if(!_formValues)
if (!_formValues || !_finishedParsingMultipartFormData)
{
NSString* contentType=[self _contentType];
if (!contentType || [contentType isEqualToString:GSWHTTPHeader_FormURLEncoded])
@ -1010,16 +1106,14 @@ method=%@, uri=%@, httpVersion=%@, headers=%@, content=%@, userInfo=%@, defaultF
}
else if ([contentType isEqualToString:GSWHTTPHeader_MultipartFormData])
{
//NSLog(@"will call _getFormValuesFromMultipartFormData");
[self _getFormValuesFromMultipartFormData];
}
else
{
NSDebugMLLog(@"requests",@"contentType=%@",contentType);
LOGObjectFnNotImplemented(); //TODO
};
NSDebugMLLog(@"requests",@"formValues=%@",_formValues);
_finishedParsingMultipartFormData=YES;
};
LOGObjectFnStop();
return _formValues;
@ -1046,6 +1140,11 @@ method=%@, uri=%@, httpVersion=%@, headers=%@, content=%@, userInfo=%@, defaultF
LOGObjectFnStop();
};
+(BOOL)_lookForIDsInCookiesFirst
{
return NO;
}
//--------------------------------------------------------------------
-(BOOL)_hasFormValues
{
@ -1054,14 +1153,13 @@ method=%@, uri=%@, httpVersion=%@, headers=%@, content=%@, userInfo=%@, defaultF
return [formValues count]>0;
};
@end
//====================================================================
@implementation GSWRequest (GSWRequestH)
//--------------------------------------------------------------------
-(void)_getFormValuesFromMultipartFormData
-(void)_getFormValuesFromMultipartFormDataOld
{
NSMutableDictionary* formValues=nil;
NSArray* contentTypes=nil;
@ -1210,7 +1308,7 @@ method=%@, uri=%@, httpVersion=%@, headers=%@, content=%@, userInfo=%@, defaultF
values=[NSArray arrayWithArray:valuesNew];
};
//NSLog(@"getFormValues 2... values=%@ key=%@",values,aName);
if (addedValues = [formValues objectForKey:aName]) {
if ((addedValues = [formValues objectForKey:aName])) {
addedValues = [NSMutableArray arrayWithArray:addedValues];
[addedValues addObjectsFromArray:values];
[formValues setObject:addedValues
@ -1250,6 +1348,137 @@ method=%@, uri=%@, httpVersion=%@, headers=%@, content=%@, userInfo=%@, defaultF
LOGObjectFnStop();
};
-(void)_getFormValuesFromMultipartFormData
{
NSMutableDictionary* formValues=nil;
GSMimeParser* parser=nil;
id key=nil;
NSData* headersData=nil;
NSMutableString* headersString=[NSMutableString string];
NSDictionary* headers=nil;
NSEnumerator* enumerator=nil;
LOGObjectFnStart();
formValues=(NSMutableDictionary*)[NSMutableDictionary dictionary];
headers=[self headers];
enumerator=[headers keyEnumerator];
while((key=[enumerator nextObject]))
{
NSArray* value=[headers objectForKey:key];
int i=0;
int count=[value count];
for(i=0;i<count;i++)
[headersString appendFormat:@"%@: %@\n",
key,[value objectAtIndex:i]];
};
[headersString appendString:@"\n"];
NSDebugMLog(@"headersString=%@",headersString);
headersData=[headersString dataUsingEncoding:NSISOLatin1StringEncoding];
parser=[GSMimeParser mimeParser];
[parser parse:headersData];
if ([parser parse:_content])
[parser parse:nil];
NSDebugMLog(@"[parser isComplete]=%d",[parser isComplete]);
if ([parser isComplete] == NO)
{
//TODO
}
else
{
GSMimeDocument* document = [parser mimeDocument];
NSArray* content=[document content];
NSString* contentSubType=[document contentSubType];
NSDebugMLog(@"document=%@",document);
NSDebugMLog(@"contentType=%@",[document contentType]);
NSDebugMLog(@"contentSubType=%@",[document contentSubType]);
if ([contentSubType isEqual:@"form-data"])
{
NSDebugMLog(@"contentID=%@",[document contentID]);
NSDebugMLog(@"[document allHeaders]=%@",[document allHeaders]);
NSDebugMLog(@"[document content]=%@",[document content]);
NSDebugMLog(@"[document content] class=%@",[[document content] class]);
NSDebugMLog(@"[document content]=%@",[document content]);
if (![content isKindOfClass:[NSArray class]])
{
//TODO
}
else
{
int i=0;
int count=[content count];
for(i=0;i<count;i++)
{
GSMimeDocument* aDoc=[content objectAtIndex:i];
GSMimeHeader* contentDispositionHeader=nil;
NSString* contentDispositionValue=nil;
NSDictionary* contentDispositionParams=nil;
id aDocContent=nil;
NSAssert2([aDoc isKindOfClass:[GSMimeDocument class]],
@"Document is not a GSMimeDocument but a %@:\n%@",
[aDoc class],aDoc);
NSDebugMLog(@"aDoc=%@",aDoc);
aDocContent=[aDoc content];
NSDebugMLog(@"aDocContent=%@",aDocContent);
NSDebugMLog(@"contentType=%@",[aDoc contentType]);
NSDebugMLog(@"contentSubType=%@",[aDoc contentSubType]);
NSDebugMLog(@"contentID=%@",[aDoc contentID]);
contentDispositionHeader=[aDoc headerNamed:@"content-disposition"];
NSDebugMLog(@"contentDispositionHeader=%@",contentDispositionHeader);
contentDispositionValue=[contentDispositionHeader value];
contentDispositionParams=[contentDispositionHeader parameters];
NSDebugMLog(@"contentDispositionValue=%@",contentDispositionValue);
NSDebugMLog(@"contentDispositionParams=%@",contentDispositionParams);
NSDebugMLog(@"aDoc allHeaders=%@",[aDoc allHeaders]);
NSDebugMLog(@"aDocContent class=%@",[aDocContent class]);
if ([contentDispositionValue isEqual:@"form-data"])
{
NSString* formDataName=[contentDispositionParams objectForKey:@"name"];
NSDebugMLLog(@"requests",@"formDataName=%@",
formDataName);
if (!formDataName)
{
ExceptionRaise(@"GSWRequest",
@"GSWRequest: No name \n%@\n",
aDoc);
}
else
{
NSString* paramName=nil;
NSEnumerator* paramNamesEnumerator=[contentDispositionParams keyEnumerator];
while((paramName=[paramNamesEnumerator nextObject]))
{
NSDebugMLLog(@"requests",@"paramName=%@",paramName);
if (![paramName isEqualToString:@"name"])
{
NSString* paramFormValueName=nil;
id paramValue=nil;
paramValue=[contentDispositionParams objectForKey:paramName];
NSDebugMLLog(@"requests",@"paramValue=%@",paramValue);
paramFormValueName=[NSString stringWithFormat:@"%@.%@",formDataName,paramName];
NSDebugMLLog(@"requests",@"paramFormValueName=%@",paramFormValueName);
[formValues setObject:[NSArray arrayWithObject:paramValue]
forKey:paramFormValueName];
};
};
if (aDocContent)
{
[formValues setObject:[NSArray arrayWithObject:aDocContent]
forKey:formDataName];
};
};
};
};
};
};
};
ASSIGN(_formValues,formValues);
NSDebugMLog(@"_formValues=%@",_formValues);
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(NSArray*)_decodeMultipartBody:(NSData*)aBody
boundary:(NSString*)aBoundary
@ -1293,7 +1522,7 @@ method=%@, uri=%@, httpVersion=%@, headers=%@, content=%@, userInfo=%@, defaultF
NSString* _dataString=nil;
_dataString=[[[NSString alloc]initWithData:tmpData
encoding:NSISOLatin1StringEncoding]autorelease];
NSDebugMLLog(@"requests",@"_tmpDataString=%@",_dataString);
NSDebugMLLog(@"requests",@"_tmpDataString=[\n%@\n]",_dataString);
}
else
{
@ -1337,7 +1566,7 @@ method=%@, uri=%@, httpVersion=%@, headers=%@, content=%@, userInfo=%@, defaultF
NSString* dataString=nil;
dataString=[[[NSString alloc]initWithData:tmpData
encoding:NSISOLatin1StringEncoding]autorelease];
NSDebugMLLog(@"requests",@"tmpDataString=%@",dataString);
NSDebugMLLog(@"requests",@"tmpDataString=[\n%@\n]",dataString);
}
else
@ -1630,6 +1859,8 @@ into
pageName=[uriElements objectForKey:GSWKey_PageName[GSWebNamingConv]];
if (!pageName)
pageName=[uriElements objectForKey:GSWKey_PageName[GSWebNamingConvInversed]];
NSDebugMLLog(@"requests",@"request %p: pageName=%@",
self,pageName);
return pageName;
};
@ -1665,220 +1896,213 @@ into
//NDFN
-(NSDictionary*)uriOrFormOrCookiesElements
{
NSString* tmpString=nil;
NSMutableDictionary* uriElements=nil;
LOGObjectFnStart();
uriElements=[self uriElements];
NSDebugMLLog(@"requests",@"uriElements=%@",uriElements);
if (![uriElements objectForKey:GSWKey_SessionID[GSWebNamingConv]])
{
tmpString=[uriElements objectForKey:GSWKey_SessionID[GSWebNamingConvInversed]];
if (!tmpString)
{
tmpString=[self formValueForKey:GSWKey_SessionID[GSWebNamingConv]];
if (!tmpString)
{
tmpString=[self formValueForKey:GSWKey_SessionID[GSWebNamingConvInversed]];
if (!tmpString)
{
tmpString=[self cookieValueForKey:GSWKey_SessionID[GSWebNamingConv]];
if (!tmpString)
{
tmpString=[self cookieValueForKey:GSWKey_SessionID[GSWebNamingConvInversed]];
};
};
};
};
if (tmpString)
[uriElements setObject:tmpString
forKey:GSWKey_SessionID[GSWebNamingConv]];
};
if (![uriElements objectForKey:GSWKey_ContextID[GSWebNamingConv]])
{
tmpString=[uriElements objectForKey:GSWKey_ContextID[GSWebNamingConvInversed]];
if (!tmpString)
{
tmpString=[self formValueForKey:GSWKey_ContextID[GSWebNamingConv]];
if (!tmpString)
{
tmpString=[self formValueForKey:GSWKey_ContextID[GSWebNamingConvInversed]];
if (!tmpString)
{
tmpString=[self cookieValueForKey:GSWKey_ContextID[GSWebNamingConv]];
if (!tmpString)
{
tmpString=[self cookieValueForKey:GSWKey_ContextID[GSWebNamingConvInversed]];
};
};
};
};
if (tmpString)
[uriElements setObject:tmpString
forKey:GSWKey_ContextID[GSWebNamingConv]];
};
if (![uriElements objectForKey:GSWKey_ElementID[GSWebNamingConv]])
{
tmpString=[uriElements objectForKey:GSWKey_ElementID[GSWebNamingConvInversed]];
if (!tmpString)
{
tmpString=[self formValueForKey:GSWKey_ElementID[GSWebNamingConv]];
if (!tmpString)
{
tmpString=[self formValueForKey:GSWKey_ElementID[GSWebNamingConvInversed]];
if (!tmpString)
{
tmpString=[self cookieValueForKey:GSWKey_ElementID[GSWebNamingConv]];
if (!tmpString)
{
tmpString=[self cookieValueForKey:GSWKey_ElementID[GSWebNamingConvInversed]];
};
};
};
};
if (tmpString)
[uriElements setObject:tmpString
forKey:GSWKey_ContextID[GSWebNamingConv]];
};
if (![uriElements objectForKey:GSWKey_ElementID[GSWebNamingConv]])
{
tmpString=[uriElements objectForKey:GSWKey_ElementID[GSWebNamingConvInversed]];
if (!tmpString)
{
tmpString=[self formValueForKey:GSWKey_ElementID[GSWebNamingConv]];
if (!tmpString)
{
tmpString=[self formValueForKey:GSWKey_ElementID[GSWebNamingConvInversed]];
if (!tmpString)
{
tmpString=[self cookieValueForKey:GSWKey_ElementID[GSWebNamingConv]];
if (!tmpString)
{
tmpString=[self cookieValueForKey:GSWKey_ElementID[GSWebNamingConvInversed]];
};
};
};
};
if (tmpString)
[uriElements setObject:tmpString
forKey:GSWKey_ContextID[GSWebNamingConv]];
};
if (![uriElements objectForKey:GSWKey_InstanceID[GSWebNamingConv]])
{
tmpString=[uriElements objectForKey:GSWKey_InstanceID[GSWebNamingConvInversed]];
if (!tmpString)
{
tmpString=[self formValueForKey:GSWKey_InstanceID[GSWebNamingConv]];
if (!tmpString)
{
tmpString=[self formValueForKey:GSWKey_InstanceID[GSWebNamingConvInversed]];
if (!tmpString)
{
tmpString=[self cookieValueForKey:GSWKey_InstanceID[GSWebNamingConv]];
if (!tmpString)
{
tmpString=[self cookieValueForKey:GSWKey_InstanceID[GSWebNamingConvInversed]];
};
};
};
};
if (tmpString)
[uriElements setObject:tmpString
forKey:GSWKey_InstanceID[GSWebNamingConv]];
};
if (![uriElements objectForKey:GSWKey_Data[GSWebNamingConv]])
{
tmpString=[uriElements objectForKey:GSWKey_Data[GSWebNamingConvInversed]];
if (!tmpString)
{
tmpString=[self formValueForKey:GSWKey_Data[GSWebNamingConv]];
if (!tmpString)
{
tmpString=[self formValueForKey:GSWKey_Data[GSWebNamingConvInversed]];
};
};
if (tmpString)
[uriElements setObject:tmpString
forKey:GSWKey_Data[GSWebNamingConv]];
};
NSDebugMLLog(@"requests",@"uriElements=%@",uriElements);
LOGObjectFnStop();
return uriElements;
return [self uriOrFormOrCookiesElementsByLookingForCookieFirst:[[self class]_lookForIDsInCookiesFirst]];
};
//--------------------------------------------------------------------
//NDFN
-(NSMutableDictionary*)uriElements
-(id)uriOrFormOrCookiesElementForKey:(NSString*)key
byLookingForCookieFirst:(BOOL)lookCookieFirst
{
id element=nil;
LOGObjectFnStart();
NSDebugMLLog(@"requests",@"request %p: key=%@",
self,key);
if (lookCookieFirst)
element=[self cookieValueForKey:key];
if (!element)
{
element=[self uriElementForKey:key];
if (!element)
{
element=[self formValueForKey:key];
if (!element && !lookCookieFirst)
element=[self cookieValueForKey:key];
};
};
NSDebugMLLog(@"requests",@"request %p: key=%@ element=%@",
self,key,element);
LOGObjectFnStop();
return element;
}
//--------------------------------------------------------------------
//NDFN
-(NSDictionary*)uriOrFormOrCookiesElementsByLookingForCookieFirst:(BOOL)lookCookieFirst
{
NSMutableDictionary* elements=nil;
NSString* tmpString=nil;
LOGObjectFnStart();
elements=(NSMutableDictionary*)[NSMutableDictionary dictionary];
//SessionID
tmpString=[self sessionIDFromValuesOrCookieByLookingForCookieFirst:lookCookieFirst];
if (tmpString)
[elements setObject:tmpString
forKey:GSWKey_SessionID[GSWebNamingConv]];
//PageName
tmpString=[self uriOrFormOrCookiesElementForKey:GSWKey_PageName[GSWebNamingConv]
byLookingForCookieFirst:lookCookieFirst];
if (!tmpString)
{
tmpString=[self uriOrFormOrCookiesElementForKey:GSWKey_PageName[GSWebNamingConvInversed]
byLookingForCookieFirst:lookCookieFirst];
};
if (tmpString)
[elements setObject:tmpString
forKey:GSWKey_PageName[GSWebNamingConv]];
//ContextID
tmpString=[self uriOrFormOrCookiesElementForKey:GSWKey_ContextID[GSWebNamingConv]
byLookingForCookieFirst:lookCookieFirst];
if (!tmpString)
{
tmpString=[self uriOrFormOrCookiesElementForKey:GSWKey_ContextID[GSWebNamingConvInversed]
byLookingForCookieFirst:lookCookieFirst];
};
if (tmpString)
[elements setObject:tmpString
forKey:GSWKey_ContextID[GSWebNamingConv]];
//ElementID
tmpString=[self uriOrFormOrCookiesElementForKey:GSWKey_ElementID[GSWebNamingConv]
byLookingForCookieFirst:lookCookieFirst];
if (!tmpString)
{
tmpString=[self uriOrFormOrCookiesElementForKey:GSWKey_ElementID[GSWebNamingConvInversed]
byLookingForCookieFirst:lookCookieFirst];
};
if (tmpString)
[elements setObject:tmpString
forKey:GSWKey_ElementID[GSWebNamingConv]];
//InstanceID
tmpString=[self uriOrFormOrCookiesElementForKey:GSWKey_InstanceID[GSWebNamingConv]
byLookingForCookieFirst:lookCookieFirst];
if (!tmpString)
{
tmpString=[self uriOrFormOrCookiesElementForKey:GSWKey_InstanceID[GSWebNamingConvInversed]
byLookingForCookieFirst:lookCookieFirst];
};
if (tmpString)
[elements setObject:tmpString
forKey:GSWKey_InstanceID[GSWebNamingConv]];
//DataID
tmpString=[self uriOrFormOrCookiesElementForKey:GSWKey_Data[GSWebNamingConv]
byLookingForCookieFirst:lookCookieFirst];
if (!tmpString)
{
tmpString=[self uriOrFormOrCookiesElementForKey:GSWKey_Data[GSWebNamingConvInversed]
byLookingForCookieFirst:lookCookieFirst];
};
if (tmpString)
[elements setObject:tmpString
forKey:GSWKey_Data[GSWebNamingConv]];
NSDebugMLLog(@"requests",@"elements=%@",elements);
LOGObjectFnStop();
return elements;
};
//--------------------------------------------------------------------
-(NSDictionary*)_uriElements
{
//OK
NSMutableDictionary* dict=nil;
NSArray* requestHandlerPathArray=nil;
int index=0;
NSString* tmpString=nil;
NSString* gswpage=nil;
NSString* gswsid=nil;
NSString* gswcid=nil;
NSString* gsweid=nil;
NSString* gswinst=nil;
NSString* requestHandlerKey=nil;
int applicationNumber;
LOGObjectFnStart();
dict=[[NSMutableDictionary new] autorelease];
//NEW//TODO
requestHandlerKey=[((GSWDynamicURLString*)[self uri]) urlRequestHandlerKey];
NSDebugMLLog(@"requests",@"requestHandlerKey=%@",requestHandlerKey);
if (!requestHandlerKey
|| (![requestHandlerKey isEqualToString:GSWDirectActionRequestHandlerKey[GSWebNamingConv]]
&&![requestHandlerKey isEqualToString:GSWDirectActionRequestHandlerKey[GSWebNamingConvInversed]]))
if (!_uriElements)
{
requestHandlerPathArray=[self requestHandlerPathArray];
NSDebugMLLog(@"requests",@"requestHandlerPathArray=%@",requestHandlerPathArray);
if ([requestHandlerPathArray count]>index)
NSMutableDictionary* dict=nil;
NSArray* requestHandlerPathArray=nil;
int index=0;
NSString* tmpString=nil;
NSString* gswpage=nil;
NSString* gswsid=nil;
NSString* gswcid=nil;
NSString* gsweid=nil;
NSString* gswinst=nil;
NSString* requestHandlerKey=nil;
int applicationNumber;
dict=[[NSMutableDictionary new] autorelease];
NSDebugMLLog(@"requests",@"request %@",self);
requestHandlerKey=[((GSWDynamicURLString*)[self uri]) urlRequestHandlerKey];
NSDebugMLLog(@"requests",@"request %p: requestHandlerKey=%@",
self,requestHandlerKey);
if (!requestHandlerKey
|| (![requestHandlerKey isEqualToString:GSWDirectActionRequestHandlerKey[GSWebNamingConv]]
&&![requestHandlerKey isEqualToString:GSWDirectActionRequestHandlerKey[GSWebNamingConvInversed]]))
{
tmpString=[requestHandlerPathArray objectAtIndex:index];
NSDebugMLLog(@"requests",@"tmpString=%@",tmpString);
if ([tmpString hasSuffix:GSWPagePSuffix[GSWebNamingConv]])
{
gswpage=[tmpString stringByDeletingSuffix:GSWPagePSuffix[GSWebNamingConv]];
NSDebugMLLog(@"requests",@"gswpage=%@",gswpage);
index++;
}
else if ([tmpString hasSuffix:GSWPagePSuffix[GSWebNamingConvInversed]])
{
gswpage=[tmpString stringByDeletingSuffix:GSWPagePSuffix[GSWebNamingConvInversed]];
NSDebugMLLog(@"requests",@"gswpage=%@",gswpage);
index++;
};
requestHandlerPathArray=[self requestHandlerPathArray];
NSDebugMLLog(@"requests",@"request %p: requestHandlerPathArray=%@",
self,requestHandlerPathArray);
if ([requestHandlerPathArray count]>index)
{
gswsid=[requestHandlerPathArray objectAtIndex:index];
NSDebugMLLog(@"requests",@"gswsid=%@",gswsid);
index++;
tmpString=[requestHandlerPathArray objectAtIndex:index];
NSDebugMLLog(@"requests",@"rquest %p: tmpString=%@",
self,tmpString);
if ([tmpString hasSuffix:GSWPagePSuffix[GSWebNamingConv]])
{
gswpage=[tmpString stringByDeletingSuffix:GSWPagePSuffix[GSWebNamingConv]];
NSDebugMLLog(@"requests",@"request %p: gswpage=%@",
self,gswpage);
index++;
}
else if ([tmpString hasSuffix:GSWPagePSuffix[GSWebNamingConvInversed]])
{
gswpage=[tmpString stringByDeletingSuffix:GSWPagePSuffix[GSWebNamingConvInversed]];
NSDebugMLLog(@"requests",@"request %p: gswpage=%@",
self,gswpage);
index++;
};
if ([requestHandlerPathArray count]>index)
{
NSString* senderID=[requestHandlerPathArray objectAtIndex:index];
NSDebugMLLog(@"requests",@"senderID=%@",senderID);
gswsid=[requestHandlerPathArray objectAtIndex:index];
NSDebugMLLog(@"requests",@"request %p: gswsid=%@",
self,gswsid);
index++;
if (senderID && [senderID length]>0)
if ([requestHandlerPathArray count]>index)
{
NSArray* senderIDParts=[senderID componentsSeparatedByString:@"."];
NSDebugMLLog(@"requests",@"senderIDParts=%@",senderIDParts);
if ([senderIDParts count]>0)
NSString* senderID=[requestHandlerPathArray objectAtIndex:index];
NSDebugMLLog(@"requests",@"senderID=%@",senderID);
index++;
if (senderID && [senderID length]>0)
{
tmpString=[senderIDParts objectAtIndex:0];
NSDebugMLLog(@"requests",@"tmpString=%@",tmpString);
if (tmpString && [tmpString length]>0)
gswcid=tmpString;
if ([senderIDParts count]>1)
NSArray* senderIDParts=[senderID componentsSeparatedByString:@"."];
NSDebugMLLog(@"requests",@"request %p: senderIDParts=%@",
self,senderIDParts);
if ([senderIDParts count]>0)
{
tmpString=[[senderIDParts subarrayWithRange:
NSMakeRange(1,[senderIDParts count]-1)]
componentsJoinedByString:@"."];
NSDebugMLLog(@"requests",@"tmpString=%@",tmpString);
tmpString=[senderIDParts objectAtIndex:0];
NSDebugMLLog(@"requests",@"request %p: tmpString=%@",
self,tmpString);
if (tmpString && [tmpString length]>0)
gswcid=tmpString;
if ([senderIDParts count]>1)
{
gsweid=tmpString;
NSDebugMLLog(@"requests",@"gsweid=%@",gsweid);
tmpString=[[senderIDParts subarrayWithRange:
NSMakeRange(1,[senderIDParts count]-1)]
componentsJoinedByString:@"."];
NSDebugMLLog(@"requests",@"request %p: tmpString=%@",
self,tmpString);
if (tmpString && [tmpString length]>0)
{
gsweid=tmpString;
NSDebugMLLog(@"requests",@"request %p: gsweid=%@",
self,gsweid);
};
};
};
};
@ -1886,40 +2110,42 @@ into
};
};
};
};
if (gswpage)
[dict setObject:gswpage
forKey:GSWKey_PageName[GSWebNamingConv]];
if (gswpage)
[dict setObject:gswpage
forKey:GSWKey_PageName[GSWebNamingConv]];
if (gswsid)
[dict setObject:gswsid
forKey:GSWKey_SessionID[GSWebNamingConv]];
if (gswsid)
[dict setObject:gswsid
forKey:GSWKey_SessionID[GSWebNamingConv]];
if (gswcid)
[dict setObject:gswcid
forKey:GSWKey_ContextID[GSWebNamingConv]];
if (gswcid)
[dict setObject:gswcid
forKey:GSWKey_ContextID[GSWebNamingConv]];
if (gsweid)
[dict setObject:gsweid
forKey:GSWKey_ElementID[GSWebNamingConv]];
if (gsweid)
[dict setObject:gsweid
forKey:GSWKey_ElementID[GSWebNamingConv]];
applicationNumber=[_uri urlApplicationNumber];
if (applicationNumber<0)
{
NSString* tmpString2=[self cookieValueForKey:GSWKey_InstanceID[GSWebNamingConv]];
if (!tmpString2)
tmpString2=[self cookieValueForKey:GSWKey_InstanceID[GSWebNamingConvInversed]];
if (tmpString2)
applicationNumber=[gswinst intValue];
applicationNumber=[_uri urlApplicationNumber];
if (applicationNumber<0)
{
NSString* tmpString2=[self cookieValueForKey:GSWKey_InstanceID[GSWebNamingConv]];
if (!tmpString2)
tmpString2=[self cookieValueForKey:GSWKey_InstanceID[GSWebNamingConvInversed]];
if (tmpString2)
applicationNumber=[gswinst intValue];
};
if (applicationNumber>=0)
[dict setObject:[NSString stringWithFormat:@"%d",applicationNumber]
forKey:GSWKey_InstanceID[GSWebNamingConv]];
ASSIGN(_uriElements,[NSDictionary dictionaryWithDictionary:dict]);
NSDebugMLLog(@"requests",@"request %@: _uriElements=%@",
self,_uriElements);
};
if (applicationNumber>=0)
[dict setObject:[NSString stringWithFormat:@"%d",applicationNumber]
forKey:GSWKey_InstanceID[GSWebNamingConv]];
NSDebugMLLog(@"requests",@"AA dict=%@",dict);
LOGObjectFnStop();
return dict;
return _uriElements;
};
@end

View file

@ -1,6 +1,6 @@
/** GSWResponse.h - <title>GSWeb: Class GSWResponse</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
@ -59,6 +59,7 @@
-(id)copyWithZone:(NSZone*)zone;
-(NSData*)content;
-(void)willSend;//NDFN
-(void)forceFinalizeInContext;
-(NSString*)headerForKey:(NSString*)key;
-(NSArray*)headerKeys;
-(NSArray*)headersForKey:(NSString*)key;
@ -125,6 +126,9 @@
-(void)_finalizeInContext:(GSWContext*)context;
-(void)_initContentData;
-(void)_appendContentAsciiString:(NSString*)string;
-(void)_appendTagAttribute:(NSString*)attributeName
value:(id)value
escapingHTMLAttributeValue:(BOOL)escape;
@end
@ -184,5 +188,33 @@
forRequest:(GSWRequest*)request;
@end
//====================================================================
@interface GSWResponse (GSWResponseRedirected)
-(void)_generateRedirectResponseWithMessage:(NSString*)message
location:(NSString*)location
isDefinitive:(BOOL)isDefinitive;
+(GSWResponse*)generateRedirectResponseWithMessage:(NSString*)message
location:(NSString*)location
isDefinitive:(BOOL)isDefinitive
inContext:(GSWContext*)aContext
forRequest:(GSWRequest*)aRequest;
+(GSWResponse*)generateRedirectResponseWithMessage:(NSString*)message
location:(NSString*)location
isDefinitive:(BOOL)isDefinitive;
+(GSWResponse*)generateRedirectDefaultResponseWithLocation:(NSString*)location
isDefinitive:(BOOL)isDefinitive
inContext:(GSWContext*)aContext
forRequest:(GSWRequest*)aRequest;
+(GSWResponse*)generateRedirectDefaultResponseWithLocation:(NSString*)location
isDefinitive:(BOOL)isDefinitive;
@end
#endif //_GSWResponse_h__

View file

@ -1,12 +1,13 @@
/** GSWResponse.m - <title>GSWeb: Class GSWResponse</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
$Revision$
$Date$
$Id$
This file is part of the GNUstep Web Library.
@ -27,15 +28,35 @@
</license>
**/
static char rcsId[] = "$Id$";
static const char rcsId[]="$Id$";
#include <GSWeb/GSWeb.h>
//====================================================================
@implementation GSWResponse
NSStringEncoding globalDefaultEncoding=NSISOLatin1StringEncoding;
static NSString* disabledCacheDateString=nil;
static NSArray* cacheControlHeaderValues=nil;
//--------------------------------------------------------------------
+(void)initialize
{
if (self==[GSWResponse class])
{
// So cache date stamp will be set to earlier date
ASSIGN(disabledCacheDateString,[[NSCalendarDate date] htmlDescription]);
// Other cache control headers
ASSIGN(cacheControlHeaderValues,([NSArray arrayWithObjects:@"private",
@"no-cache",
@"no-store",
@"must-revalidate",
@"max-age=0",
nil]));
};
};
//--------------------------------------------------------------------
// init
@ -189,7 +210,10 @@ NSStringEncoding globalDefaultEncoding=NSISOLatin1StringEncoding;
forKey:(NSString*)key
{
//OK
id object=[_headers objectForKey:key];
id object=nil;
NSAssert(header,@"No header");
NSAssert(key,@"No header key");
object=[_headers objectForKey:key];
if (object)
[self setHeaders:[object arrayByAddingObject:header]
forKey:key];
@ -205,6 +229,8 @@ NSStringEncoding globalDefaultEncoding=NSISOLatin1StringEncoding;
forKey:(NSString*)key
{
//OK
NSAssert(headers,@"No headers");
NSAssert(key,@"No header key");
if (!_headers)
_headers=[NSMutableDictionary new];
[_headers setObject:headers
@ -227,7 +253,8 @@ NSStringEncoding globalDefaultEncoding=NSISOLatin1StringEncoding;
keyEnum = [headerDictionary keyEnumerator];
while ((headerName = [keyEnum nextObject]))
{
[self setHeaders:[NSArray arrayWithObject:[headerDictionary objectForKey:headerName]] forKey:headerName];
[self setHeaders:[NSArray arrayWithObject:[headerDictionary objectForKey:headerName]]
forKey:headerName];
};
};
};
@ -287,22 +314,22 @@ NSStringEncoding globalDefaultEncoding=NSISOLatin1StringEncoding;
-(void)disableClientCaching
{
//OK
NSString* dateString=nil;
LOGObjectFnStart();
if (!_isClientCachingDisabled)
{
dateString=[[NSCalendarDate date] htmlDescription];
NSDebugMLLog(@"low",@"dateString:%@",dateString);
[self setHeader:dateString
[self setHeader:disabledCacheDateString
forKey:@"date"];
[self setHeader:dateString
[self setHeader:disabledCacheDateString
forKey:@"expires"];
[self setHeader:@"no-cache"
forKey:@"pragma"];
[self setHeaders:[NSArray arrayWithObjects:@"private",@"no-cache",@"max-age=0",nil]
forKey:@"cache-control"];
//TODO later
/*
if([GSWApp _allowsCacheControlHeader])
[self setHeaders:cacheControlHeaderValues
forKey:@"cache-control"];
*/
_isClientCachingDisabled=YES;
};
LOGObjectFnStop();
@ -389,7 +416,7 @@ NSStringEncoding globalDefaultEncoding=NSISOLatin1StringEncoding;
newData=[string dataUsingEncoding:_contentEncoding];
NSAssert3(newData,@"Can't create data from %@ \"%s\" using encoding %d",
[string class],
([string isKindOfClass:[NSString class]] ? [string lossyCString] : @"**Not a string**"),
([string isKindOfClass:[NSString class]] ? [string lossyCString] : "**Not a string**"),
(int)_contentEncoding);
NSDebugMLLog(@"low",@"newData=%@",newData);
[_contentData appendData:newData];
@ -403,7 +430,8 @@ NSStringEncoding globalDefaultEncoding=NSISOLatin1StringEncoding;
-(void)appendDebugCommentContentString:(NSString*)aString
{
#ifndef NDEBUG
[self appendContentString:[NSString stringWithFormat:@"\n<!-- %@ -->\n",aString]];
if (GSDebugSet(@"debugComments") == YES)
[self appendContentString:[NSString stringWithFormat:@"\n<!-- %@ -->\n",aString]];
#endif
};
@ -522,7 +550,8 @@ NSStringEncoding globalDefaultEncoding=NSISOLatin1StringEncoding;
NSMutableArray* cookies=nil;
LOGObjectFnStart();
cookies=[self allocCookiesIFND];
[cookies addObject:cookie];
if (cookie)
[cookies addObject:cookie];
LOGObjectFnStop();
};
@ -532,7 +561,8 @@ NSStringEncoding globalDefaultEncoding=NSISOLatin1StringEncoding;
NSMutableArray* cookies=nil;
LOGObjectFnStart();
cookies=[self allocCookiesIFND];
[cookies removeObject:cookie];
if (cookie)
[cookies removeObject:cookie];
LOGObjectFnStop();
};
@ -560,6 +590,7 @@ NSStringEncoding globalDefaultEncoding=NSISOLatin1StringEncoding;
{
cookie=[cookies objectAtIndex:i];
cookieString=[cookie headerValue];
NSAssert(cookieString,@"No cookie HeaderValue");
[strings addObject:cookieString];
};
};
@ -660,6 +691,20 @@ NSStringEncoding globalDefaultEncoding=NSISOLatin1StringEncoding;
LOGObjectFnStop();
};
-(void)_appendTagAttribute:(NSString*)attributeName
value:(id)value
escapingHTMLAttributeValue:(BOOL)escape
{
[self appendContentCharacter:' '];
[self _appendContentAsciiString:attributeName];
[self _appendContentAsciiString:@"=\""];
if (escape)
[self _appendContentAsciiString:[[self class]stringByEscapingHTMLAttributeValue:value]];
else
[self _appendContentAsciiString:value];
[self appendContentCharacter:'"'];
};
@end
//====================================================================
@ -711,8 +756,6 @@ NSStringEncoding globalDefaultEncoding=NSISOLatin1StringEncoding;
//--------------------------------------------------------------------
-(GSWResponse*)generateResponse
{
//LOGObjectFnNotImplemented(); //TODOFN
//return nil;
return self;
};
@ -813,23 +856,9 @@ NSStringEncoding globalDefaultEncoding=NSISOLatin1StringEncoding;
[response setHTTPVersion:httpVersion];
}
[response setStatus:302];
locationURLString = [NSString stringWithFormat:@"%@/%@.gswa",
[aRequest adaptorPrefix],
[aRequest applicationName]];
if (locationURLString)
[response setHeader:locationURLString
forKey:@"location"];
[response setHeader:@"text/html"
forKey:@"content-type"];
[response setHeader:@"YES"
forKey:@"x-gsweb-refusing-redirection"];
if (aContext)
{
[aContext _setResponse:response];
}
message = [NSString stringWithFormat:@"Sorry, your request could not immediately be processed. Please try this URL: <a href=\"%@\">%@</a>\nConnection closed by foreign host.",
locationURLString,
@ -837,11 +866,15 @@ NSStringEncoding globalDefaultEncoding=NSISOLatin1StringEncoding;
responseString=[NSString stringWithFormat:@"<HTML>\n<TITLE>GNUstepWeb</TITLE>\n</HEAD>\n<BODY bgcolor=\"white\">\n<CENTER>\n%@\n</CENTER>\n</BODY>\n</HTML>\n",
message];
//[[response class]stringByEscapingHTMLString:message]];
[response appendContentString:responseString];
[response setHeader:[NSString stringWithFormat:@"%d",[[response content] length]]
forKey:@"content-length"];
[response _generateRedirectResponseWithMessage:responseString
location:locationURLString
isDefinitive:NO];
if (aContext)
{
[aContext _setResponse:response];
}
};
LOGClassFnStop();
return response;
@ -849,3 +882,125 @@ NSStringEncoding globalDefaultEncoding=NSISOLatin1StringEncoding;
@end
//====================================================================
@implementation GSWResponse (GSWResponseRedirected)
-(void)_generateRedirectResponseWithMessage:(NSString*)message
location:(NSString*)location
isDefinitive:(BOOL)isDefinitive
{
if (message)
{
[self appendContentString:message];
[self setHeader:[NSString stringWithFormat:@"%d",[[self content] length]]
forKey:@"content-length"];
};
if (isDefinitive)
[self setStatus:301]; // redirect definitive !
else
[self setStatus:302]; // redirect temporary !
[self setHeader:location
forKey:@"Location"];
[self setHeader:@"text/html"
forKey:@"content-type"];
[self setHeader:@"YES"
forKey:@"x-gsweb-refusing-redirection"];
}
//--------------------------------------------------------------------
//
//Redirect Response
+(GSWResponse*)generateRedirectResponseWithMessage:(NSString*)message
location:(NSString*)location
isDefinitive:(BOOL)isDefinitive
inContext:(GSWContext*)aContext
forRequest:(GSWRequest*)aRequest
{
GSWResponse* response=nil;
NSString* httpVersion=nil;
LOGClassFnStart();
response=[[self new]autorelease];
if (response)
{
if (aContext && [aContext request])
{
aRequest=[aContext request];
}
httpVersion=[aRequest httpVersion];
if (httpVersion)
{
[response setHTTPVersion:httpVersion];
}
[response _generateRedirectResponseWithMessage:message
location:location
isDefinitive:isDefinitive];
if (aContext)
{
[aContext _setResponse:response];
}
};
LOGClassFnStop();
return response;
};
//--------------------------------------------------------------------
//
//Redirect Response
+(GSWResponse*)generateRedirectResponseWithMessage:(NSString*)message
location:(NSString*)location
isDefinitive:(BOOL)isDefinitive
{
GSWResponse* response=nil;
LOGClassFnStart();
response=[self generateRedirectResponseWithMessage:message
location:location
isDefinitive:isDefinitive
inContext:nil
forRequest:nil];
LOGClassFnStop();
return response;
};
//--------------------------------------------------------------------
+(GSWResponse*)generateRedirectDefaultResponseWithLocation:(NSString*)location
isDefinitive:(BOOL)isDefinitive
inContext:(GSWContext*)aContext
forRequest:(GSWRequest*)aRequest
{
NSString* message=nil;
GSWResponse* response=nil;
LOGClassFnStart();
message=[NSString stringWithFormat:@"This page has been moved%s to <a HREF=\"%@\">%@</a>",
(isDefinitive ? "" : " temporarily"),
location,
location];
response=[self generateRedirectResponseWithMessage:message
location:location
isDefinitive:isDefinitive
inContext:aContext
forRequest:aRequest];
LOGClassFnStop();
return response;
};
//--------------------------------------------------------------------
+(GSWResponse*)generateRedirectDefaultResponseWithLocation:(NSString*)location
isDefinitive:(BOOL)isDefinitive
{
GSWResponse* response=nil;
LOGClassFnStart();
response=[self generateRedirectDefaultResponseWithLocation:location
isDefinitive:isDefinitive
inContext:nil
forRequest:nil];
LOGClassFnStop();
return response;
};
@end

View file

@ -1,6 +1,6 @@
/** GSWServerSessionStore.h - <title>GSWeb: Class GSWServerSessionStore</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Mar 1999
@ -35,12 +35,8 @@
@interface GSWServerSessionStore : GSWSessionStore
{
NSMutableDictionary* _sessions;
GSWSessionTimeOutManager* _timeOutManager;
};
-(id)init;
-(void)dealloc;
-(id)description;
-(void)saveSessionForContext:(GSWContext*)aContext;
-(GSWSession*)restoreSessionWithID:(NSString*)aSessionID
request:(GSWRequest*)aRequest;

View file

@ -1,6 +1,6 @@
/** GSWServerSessionStore.m - <title>GSWeb: Class GSWServerSessionStore</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Mar 1999
@ -27,7 +27,7 @@
</license>
**/
static char rcsId[] = "$Id$";
static const char rcsId[] = "$Id$";
#include <GSWeb/GSWeb.h>
@ -39,11 +39,7 @@ static char rcsId[] = "$Id$";
LOGObjectFnStart();
if ((self=[super init]))
{
_timeOutManager=[GSWSessionTimeOutManager new];
_sessions=[NSMutableDictionary new];
[_timeOutManager setCallBack:@selector(removeSessionWithID:)
target:self];
[_timeOutManager startHandleTimerRefusingSessions];
};
LOGObjectFnStop();
return self;
@ -53,7 +49,6 @@ static char rcsId[] = "$Id$";
-(void)dealloc
{
DESTROY(_sessions);
DESTROY(_timeOutManager);
[super dealloc];
};
@ -68,33 +63,34 @@ static char rcsId[] = "$Id$";
};
//--------------------------------------------------------------------
/** Should be Locked **/
-(void)saveSessionForContext:(GSWContext*)aContext
{
//OK
GSWSession* session=nil;
NSString* sessionID=nil;
NSTimeInterval sessionTimeOut=0;
BOOL sessionIsTerminating=NO;
LOGObjectFnStart();
session=[aContext existingSession];
NSAssert(session,@"No session!");
NSDebugMLLog(@"sessions",@"session=%@",session);
sessionIsTerminating=[session isTerminating]; //TODO
[session setDistributionEnabled:NO];
if (!session)
{
[NSException raise:@"IllegalStateException"
format:@"Current context has no existing session. Can't save session"];
};
sessionID=[session sessionID];
NSAssert(sessionID,@"No _sessionID!");
NSDebugMLLog(@"sessions",@"_sessionID=%@",sessionID);
sessionTimeOut=[session timeOut];
[_sessions setObject:session
forKey:sessionID];
NSDebugMLLog(@"sessions",@"session=%@",session);
NSDebugMLLog(@"sessions",@"sessionTimeOut=%ld",(long)sessionTimeOut);
[_timeOutManager updateTimeOutForSessionWithID:sessionID
timeOut:sessionTimeOut];
LOGObjectFnStop();
};
//--------------------------------------------------------------------
/** Should be Locked **/
-(id)restoreSessionWithID:(NSString*)aSessionID
request:(GSWRequest*)aRequest
{
@ -110,6 +106,7 @@ static char rcsId[] = "$Id$";
};
//--------------------------------------------------------------------
/** Should be Locked **/
-(GSWSession*)removeSessionWithID:(NSString*)aSessionID
{
//OK

View file

@ -1,6 +1,6 @@
/** GSWSession.h - <title>GSWeb: Class GSWSession</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
@ -60,9 +60,7 @@
};
-(id)init;
-(void)dealloc;
-(id)copyWithZone:(NSZone *)zone;
+(NSString*)createSessionID;
-(NSString*)domainForIDCookies;
-(BOOL)storesIDsInURLs;

View file

@ -1,12 +1,13 @@
/** GSWSession.m - <title>GSWeb: Class GSWSession</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
$Revision$
$Date$
$Id$
This file is part of the GNUstep Web Library.
@ -27,14 +28,23 @@
</license>
**/
static char rcsId[] = "$Id$";
static const char rcsId[] = "$Id$";
#include <GSWeb/GSWeb.h>
#include <gscrypt/GSMD5.h>
#include <time.h>
#if __linux__
#include <linux/kernel.h>
#include <linux/sys.h>
#include <sys/sysinfo.h>
#endif
/*
#ifdef NOEXTENSIONS
#else
#include <extensions/GarbageCollector.h>
#endif
*/
//====================================================================
@implementation GSWSession
@ -49,7 +59,7 @@ static char rcsId[] = "$Id$";
NSTimeInterval sessionTimeOut=[GSWApplication sessionTimeOutValue];
NSDebugMLLog(@"sessions",@"sessionTimeOut=%ld",(long)sessionTimeOut);
[self setTimeOut:sessionTimeOut];
[self _initWithSessionID:[NSString stringUniqueIdWithLength:8]]; //TODO
[self _initWithSessionID:[[self class]createSessionID]];
};
LOGObjectFnStop();
return self;
@ -70,6 +80,136 @@ static char rcsId[] = "$Id$";
return clone;
};
+(NSString*)createSessionID
{
// The idea is to have uniq sessionID generated.
// Parts are:
// o a modified TimeStamp (modified because we don't want to give
// information on server exact time which can be always a security
// problem), so we can remember this sessionID for long time without conflict
// o a md5 sum of various elements
// The generated session ID is a sizeof(time_t)+16 bytes string
NSString* sessionID=nil;
NSMutableData* data=nil;
NSMutableData* md5Data=nil;
NSData* md5Sum=nil;
void* pMd5Data=NULL;
time_t ts=time(NULL);
int sizeToFill=64;
md5Data=[NSMutableData dataWithLength:64];
pMd5Data=[md5Data mutableBytes];
// initialize random generator
// We xor time stamp with a pointer so 2 sessions created at the same
// time won't have the same random generator initializer
srand(((unsigned long int)ts) ^ ((unsigned long int)md5Data));
// We randomize on 60s
ts=ts+(int)(60*rand()/(RAND_MAX+1.0));
data=[NSMutableData dataWithBytes:&ts
length:sizeof(ts)];
// Now, use some system related chnaging info (
#if __linux__
{
struct sysinfo info;
if ((sysinfo(&info)) == 0)
{
unsigned int rnd;
// >0 test is to ignore not changing elements
if (sizeToFill>=sizeof(unsigned int) && info.uptime>0)
{
rnd=(unsigned)(UINT_MAX*rand()/(RAND_MAX+1.0));
NSDebugMLog(@"UPTIME %ld",(long)info.uptime);
*((unsigned int*)pMd5Data)=(((unsigned int)(info.uptime)) ^ rnd);
sizeToFill-=sizeof(unsigned int);
pMd5Data+=sizeof(unsigned int);
};
if (sizeToFill>=sizeof(unsigned int) && info.loads[0]>0)
{
rnd=(unsigned)(UINT_MAX*rand()/(RAND_MAX+1.0));
NSDebugMLog(@"loads[0] %ld",(long)info.loads[0]);
*((unsigned int*)pMd5Data)=(((unsigned int)(info.loads[0] >> 4)) ^ rnd);
sizeToFill-=sizeof(unsigned int);
pMd5Data+=sizeof(unsigned int);
};
if (sizeToFill>=sizeof(unsigned int) && info.loads[1]>0)
{
rnd=(unsigned)(UINT_MAX*rand()/(RAND_MAX+1.0));
NSDebugMLog(@"loads[1] %ld",(long)info.loads[1]);
*((unsigned int*)pMd5Data)=(((unsigned int)(info.loads[1] >> 4)) ^ rnd);
sizeToFill-=sizeof(unsigned int);
pMd5Data+=sizeof(unsigned int);
};
if (sizeToFill>=sizeof(unsigned int) && info.loads[2]>0)
{
rnd=(unsigned)(UINT_MAX*rand()/(RAND_MAX+1.0));
NSDebugMLog(@"loads[2] %ld",(long)info.loads[2]);
*((unsigned int*)pMd5Data)=(((unsigned int)(info.loads[2] >> 4)) ^ rnd);
sizeToFill-=sizeof(unsigned int);
pMd5Data+=sizeof(unsigned int);
};
if (sizeToFill>=sizeof(unsigned int) && info.freeram>0)
{
NSDebugMLog(@"freeram %ld",(unsigned long)info.freeram);
rnd=(unsigned)(UINT_MAX*rand()/(RAND_MAX+1.0));
*((unsigned int*)pMd5Data)=(((unsigned int)(info.freeram >> 4)) ^ rnd); // Drop 4 minor bits
sizeToFill-=sizeof(unsigned int);
pMd5Data+=sizeof(unsigned int);
};
if (sizeToFill>=sizeof(unsigned int) && info.sharedram>0)
{
NSDebugMLog(@"sharedram %ld",(unsigned long)info.sharedram);
rnd=(unsigned)(UINT_MAX*rand()/(RAND_MAX+1.0));
*((unsigned int*)pMd5Data)=(((unsigned int)(info.sharedram >> 4)) ^ rnd); // Drop 4 minor bits
sizeToFill-=sizeof(unsigned int);
pMd5Data+=sizeof(unsigned int);
};
if (sizeToFill>=sizeof(unsigned int) && info.freeswap>0)
{
NSDebugMLog(@"freeswap %ld",(unsigned long)info.freeswap);
rnd=(unsigned)(UINT_MAX*rand()/(RAND_MAX+1.0));
*((unsigned int*)pMd5Data)=(((unsigned int)(info.freeswap >> 4)) ^ rnd); // Drop 4 minor bits
sizeToFill-=sizeof(unsigned int);
pMd5Data+=sizeof(unsigned int);
};
if (sizeToFill>=sizeof(unsigned int) && info.bufferram>0)
{
NSDebugMLog(@"bufferram %ld",(unsigned long)info.bufferram);
rnd=(unsigned)(UINT_MAX*rand()/(RAND_MAX+1.0));
*((unsigned int*)pMd5Data)=(((unsigned int)(info.bufferram >> 4)) ^ rnd); // Drop 4 minor bits
sizeToFill-=sizeof(unsigned int);
pMd5Data+=sizeof(unsigned int);
};
};
};
#endif
NSDebugMLog(@"sizeToFill %d",sizeToFill);
while(sizeToFill>0)
{
*((unsigned char*)pMd5Data)=(unsigned char)(256*rand()/(RAND_MAX+1.0));
sizeToFill--;
pMd5Data++;
};
//Now do md5 on bytes after sizeof(ts)
md5Sum=[GSMD5 digestOfData:md5Data];
[data appendData:md5Sum];
sessionID=DataToHexString(data);
return sessionID;
};
//--------------------------------------------------------------------
-(void)encodeWithCoder:(NSCoder*)coder
{
@ -464,6 +604,7 @@ static char rcsId[] = "$Id$";
if (stackIndex!=([_contextArrayStack count]-1))
{
[_contextArrayStack addObject:contextArray];
NSDebugMLLog(@"sessions",@"SESSION REMOVE: %p",[_contextArrayStack objectAtIndex:stackIndex]);
[_contextArrayStack removeObjectAtIndex:stackIndex];
//TODO faire pareil avec _contextArray ?
};
@ -511,13 +652,15 @@ static char rcsId[] = "$Id$";
[_permanentContextIDArray objectAtIndex:0]);
NSDebugMLLog(@"sessions",@"[permanentContextIDArray objectAtIndex:0] retainCount=%d",
(int)[[_permanentContextIDArray objectAtIndex:0] retainCount]);
NSDebugMLLog(@"sessions",@"SESSION REMOVE: %p",[_permanentContextIDArray objectAtIndex:0]);
[_permanentContextIDArray removeObjectAtIndex:0];
deletePage=[_contextRecords objectForKey:deleteContextID];
GSWLogAssertGood(deletePage);
[GSWApplication statusLogWithFormat:@"delete page of class=%@",
[deletePage class]];
NSDebugMLLog(@"sessions",@"SESSION REMOVE: %p",[permanentPageCache objectForKey:deleteContextID]);
[permanentPageCache removeObjectForKey:deleteContextID];
};
};
contextID=[context contextID];
NSAssert(contextID,@"No contextID");
@ -526,6 +669,7 @@ static char rcsId[] = "$Id$";
LOGSeriousError(@"page of class %@ contextID %@ already in permanent cache stack",
[page class],
contextID);
NSDebugMLLog(@"sessions",@"SESSION REMOVE: %p",contextID);
[_permanentContextIDArray removeObject:contextID];
if (![permanentPageCache objectForKey:contextID])
{
@ -539,6 +683,7 @@ static char rcsId[] = "$Id$";
contextID);
};
NSDebugMLLog(@"sessions",@"SESSION REPLACE: %p",[permanentPageCache objectForKey:contextID]);
[permanentPageCache setObject:page
forKey:contextID];
[_permanentContextIDArray addObject:contextID];
@ -825,12 +970,14 @@ fprintf(stderr,"session %p _releaseAutoreleasePool STOP\n",self);
[_contextArrayStack objectAtIndex:0]);
NSDebugMLLog(@"sessions",@"[contextArrayStack objectAtIndex:0] retainCount=%d",
(int)[[_contextArrayStack objectAtIndex:0] retainCount]);
NSDebugMLLog(@"sessions",@"SESSION REMOVE: %p",[_contextArrayStack objectAtIndex:0]);
[_contextArrayStack removeObjectAtIndex:0];
deleteRecord=[_contextRecords objectForKey:deleteContextID];
GSWLogAssertGood(deleteRecord);
GSWLogAssertGood([deleteRecord responsePage]);
[GSWApplication statusLogWithFormat:@"delete page of class=%@",
[[deleteRecord responsePage] class]];
NSDebugMLLog(@"sessions",@"SESSION REMOVE: %p",[_contextRecords objectForKey:deleteContextID]);
[_contextRecords removeObjectForKey:deleteContextID];
};
@ -848,6 +995,7 @@ fprintf(stderr,"session %p _releaseAutoreleasePool STOP\n",self);
LOGSeriousError(@"page of class %@ contextID %@ already in cache stack",
[page class],
contextID);
NSDebugMLLog(@"sessions",@"SESSION REMOVE: %p",contextID);
[_contextArrayStack removeObject:contextID];
if (![_contextRecords objectForKey:contextID])
{
@ -864,6 +1012,7 @@ fprintf(stderr,"session %p _releaseAutoreleasePool STOP\n",self);
[_contextArrayStack addObject:contextID];
// Add the record for this contextID in contextRecords
NSDebugMLLog(@"sessions",@"SESSION REPLACE: %p",[_contextRecords objectForKey:contextID]);
[_contextRecords setObject:transactionRecord
forKey:contextID];
NSDebugMLLog(@"sessions",@"contextArrayStack=%@",_contextArrayStack);
@ -894,19 +1043,26 @@ fprintf(stderr,"session %p _releaseAutoreleasePool STOP\n",self);
-(void)_saveCurrentPage
{
//OK
GSWComponent* component=nil;
unsigned int pageCacheSize=0;
LOGObjectFnStart();
LOGObjectFnStart();
NSAssert(_currentContext,@"currentContext");
component=[_currentContext _pageComponent];
NSAssert(component,@"No component");
pageCacheSize=[self pageCacheSize];
if (pageCacheSize>0)
if (_currentContext)
{
GSWComponent* component=[_currentContext _pageComponent];
if ([component _isPage])
{
[self savePage:component];
GSWComponent* testComponent=[self _permanentPageWithContextID:[_currentContext contextID]];
if (testComponent!=component)
{
testComponent=[self _permanentPageWithContextID:[_currentContext _requestContextID]];
if (testComponent && [self permanentPageCacheSize]>0)
{
[self savePageInPermanentCache:component];
}
else
{
if ([self pageCacheSize]>0)
[self savePage:component];
};
};
};
};
LOGObjectFnStop();
@ -1179,8 +1335,23 @@ fprintf(stderr,"session %p _releaseAutoreleasePool STOP\n",self);
[aContext addDocStructureStep:@"Append To Response"];
#endif
[aContext _setCurrentComponent:pageComponent]; //_pageElement ??
[pageComponent appendToResponse:aResponse
inContext:aContext]; //_pageComponent??
NS_DURING
{
[pageComponent appendToResponse:aResponse
inContext:aContext]; //_pageComponent??
}
NS_HANDLER
{
LOGException(@"exception in %@ appendToResponse:inContext",
[self class]);
LOGException(@"exception=%@",localException);
localException=ExceptionByAddingUserInfoObjectFrameInfo(localException,
@"In %@ appendToResponse:inContext",
[self class]);
LOGException(@"exception=%@",localException);
[localException raise];
}
NS_ENDHANDLER;
[aContext _setCurrentComponent:nil];
session=[aContext existingSession];
[session appendCookieToResponse:aResponse];

View file

@ -1,6 +1,6 @@
/** GSWSessionStore.m - <title>GSWeb: Class GSWSessionStore</title>
/** GSWSessionStore.h - <title>GSWeb: Class GSWSessionStore</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
@ -37,6 +37,7 @@
{
NSMutableSet* _usedIDs;
NSRecursiveLock* _lock;
GSWSessionTimeOutManager* _timeOutManager;
#ifndef NDEBUG
int _lockn;
#endif
@ -46,6 +47,7 @@
-(void)dealloc;
-(id)init;
-(GSWSession*)removeSessionWithID:(NSString*)aSessionID;
-(GSWSession*)restoreSessionWithID:(NSString*)aSessionID
request:(GSWRequest*)aRequest;
-(void)saveSessionForContext:(GSWContext*)aContext;
@ -63,12 +65,12 @@
-(void)lock;
@end
/*
//====================================================================
@interface GSWSessionStore (GSWSessionStoreCreation)
+(GSWSessionStore*)serverSessionStore;
@end
/*
//====================================================================
@interface GSWSessionStore (GSWSessionStoreOldFn)
+(GSWSessionStore*)cookieSessionStoreWithDistributionDomain:(NSString*)aDomain

View file

@ -1,6 +1,6 @@
/** GSWSessionStore.m - <title>GSWeb: Class GSWSessionStore</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
@ -28,8 +28,9 @@
</license>
**/
#include <GSWeb/GSWeb.h>
static const char rcsId[]="$Id$";
#include <GSWeb/GSWeb.h>
//====================================================================
@implementation GSWSessionStore
@ -42,6 +43,10 @@
{
_usedIDs=[NSMutableSet new];
_lock=[NSRecursiveLock new];
_timeOutManager=[GSWSessionTimeOutManager new];
[_timeOutManager setCallBack:@selector(removeSessionWithID:)
target:self];
[_timeOutManager startHandleTimerRefusingSessions];
[self _validateAPI];
};
LOGObjectFnStop();
@ -56,23 +61,35 @@
DESTROY(_usedIDs);
GSWLogC("Dealloc GSWSessionStore: lock");
DESTROY(_lock);
GSWLogC("Dealloc GSWSessionStore: timeOutManager");
DESTROY(_timeOutManager);
GSWLogC("Dealloc GSWSessionStore Super");
[super dealloc];
GSWLogC("End Dealloc GSWSessionStore");
};
//--------------------------------------------------------------------
-(GSWSession*)restoreSessionWithID:(NSString*)aSessionID
request:(GSWRequest*)aRequest
/** Abstract **/
-(GSWSession*)removeSessionWithID:(NSString*)aSessionID
{
LOGObjectFnNotImplemented(); //TODOFN
[self subclassResponsibility: _cmd];
return nil;
};
//--------------------------------------------------------------------
/** Abstract **/
-(GSWSession*)restoreSessionWithID:(NSString*)aSessionID
request:(GSWRequest*)aRequest
{
[self subclassResponsibility: _cmd];
return nil;
};
//--------------------------------------------------------------------
/** Abstract **/
-(void)saveSessionForContext:(GSWContext*)aContext
{
LOGObjectFnNotImplemented(); //TODOFN
[self subclassResponsibility: _cmd];
};
//--------------------------------------------------------------------
@ -92,7 +109,6 @@
NSDebugMLLog(@"sessions",@"[[NSDate date]compare:limit]==NSOrderedAscending=%d",
(int)([[NSDate date]compare:limit]==NSOrderedAscending));
while(!session && sessionUsed && [[NSDate date]compare:limit]==NSOrderedAscending)
{
BOOL tmpUsed=NO;
@ -153,62 +169,110 @@
};
//--------------------------------------------------------------------
/** Should be Locked **/
-(void)_checkInSessionForContext:(GSWContext*)aContext
{
//OK
NSString* sessionID=nil;
GSWSession* session=nil;
LOGObjectFnStart();
session=[aContext existingSession];
GSWLogAssertGood(session);
NSDebugMLLog(@"sessions",@"session=%@",session);
NS_DURING
if (!session)
{
[self saveSessionForContext:aContext];
[NSException raise:@"IllegalStateException"
format:@"Current context has no existing session. Can't save session"];
}
NS_HANDLER
else
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
@"In saveSessionForContext:");
LOGException(@"%@ (%@)",localException,[localException reason]);
[localException raise];
}
NS_ENDHANDLER;
GSWLogAssertGood(session);
NSDebugMLLog(@"sessions",@"session=%@",session);
NS_DURING
{
[session _releaseAutoreleasePool];
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
@"In [_session _releaseAutoreleasePool]");
LOGException(@"%@ (%@)",localException,[localException reason]);
[localException raise];
}
NS_ENDHANDLER;
GSWLogAssertGood(session);
NSDebugMLLog(@"sessions",@"session=%@",session);
sessionID=[session sessionID];
GSWLogAssertGood(session);
NSDebugMLLog(@"sessions",@"sessionID=%@",sessionID);
NS_DURING
{
[self _checkinSessionID:sessionID];
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
@"In _checkinSessionID");
LOGException(@"%@ (%@)",localException,[localException reason]);
[localException raise];
}
NS_ENDHANDLER;
NSString* sessionID=nil;
BOOL sessionIsTerminating=NO;
NSTimeInterval sessionTimeOut=0;
sessionID=[session sessionID];
NSAssert(sessionID,@"No _sessionID!");
NSDebugMLLog(@"sessions",@"_sessionID=%@",sessionID);
GSWLogAssertGood(session);
sessionIsTerminating=[session isTerminating];
[session setDistributionEnabled:sessionIsTerminating];
if (sessionIsTerminating)
{
NS_DURING
{
[self removeSessionWithID:sessionID];
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
@"In removeSessionWithID:");
LOGException(@"%@ (%@)",localException,[localException reason]);
[localException raise];
}
NS_ENDHANDLER;
}
else
{
NS_DURING
{
[self saveSessionForContext:aContext];
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
@"In saveSessionForContext:");
LOGException(@"%@ (%@)",localException,[localException reason]);
[localException raise];
}
NS_ENDHANDLER;
};
sessionTimeOut=[session timeOut];
NSDebugMLLog(@"sessions",@"sessionTimeOut=%ld",(long)sessionTimeOut);
[_timeOutManager updateTimeOutForSessionWithID:sessionID
timeOut:sessionTimeOut];
GSWLogAssertGood(session);
NSDebugMLLog(@"sessions",@"session=%@",session);
NS_DURING
{
[session _releaseAutoreleasePool];
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
@"In [_session _releaseAutoreleasePool]");
LOGException(@"%@ (%@)",localException,[localException reason]);
[localException raise];
}
NS_ENDHANDLER;
GSWLogAssertGood(session);
NSDebugMLLog(@"sessions",@"session=%@",session);
sessionID=[session sessionID];
GSWLogAssertGood(session);
NSDebugMLLog(@"sessions",@"sessionID=%@",sessionID);
NS_DURING
{
[self _checkinSessionID:sessionID];
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
@"In _checkinSessionID");
LOGException(@"%@ (%@)",localException,[localException reason]);
[localException raise];
}
NS_ENDHANDLER;
};
LOGObjectFnStop();
};
//--------------------------------------------------------------------
/** Should be Locked **/
-(GSWSession*)_checkOutSessionWithID:(NSString*)aSessionID
request:(GSWRequest*)aRequest
{
@ -216,7 +280,7 @@
LOGObjectFnStart();
NSDebugMLLog(@"sessions",@"aSessionID=%@",aSessionID);
NSDebugMLLog(@"sessions",@"self=%@",self);
//OK
NSDebugMLog0(@"starting:_checkoutSessionID");
[self _checkoutSessionID:aSessionID];
NSDebugMLog0(@"end of:_checkoutSessionID");
@ -227,8 +291,7 @@
if (session)
[session _createAutoreleasePool];
else
// [self checkinSessionID:aSessionID];
[self _checkinSessionID:aSessionID];
[self _checkinSessionID:aSessionID];
NSDebugMLLog(@"sessions",@"session=%@",session);
LOGObjectFnStop();
@ -236,22 +299,16 @@
};
//--------------------------------------------------------------------
/** Should be Locked **/
-(void)_checkinSessionID:(NSString*)aSessionID
{
LOGObjectFnStart();
//OK
/* if (![usedIDs containsObject:aSessionID])
{
NSDebugMLLog(@"sessions",@"SessionID=%@ not is use",aSessionID);
}
else
{*/
[_usedIDs removeObject:aSessionID];
// };
LOGObjectFnStop();
};
//--------------------------------------------------------------------
/** Should be Locked **/
-(void)_checkoutSessionID:(NSString*)aSessionID
{
//OK
@ -314,7 +371,7 @@
};
@end
//*
//====================================================================
@implementation GSWSessionStore (GSWSessionStoreCreation)

View file

@ -138,6 +138,7 @@ static char rcsId[] = "$Id$";
{
//OK
[GSWApplication statusLogWithFormat:@"Start HandleTimer"];
NSDebugMLog(@"Start HandleTimer");
// LOGObjectFnStart();
[GSWApp lockRequestHandling];
NS_DURING
@ -241,6 +242,7 @@ static char rcsId[] = "$Id$";
[GSWApp unlockRequestHandling];
// LOGObjectFnStop();
[GSWApplication statusLogWithFormat:@"Stop HandleTimer"];
NSDebugMLog(@"Stop HandleTimer");
};
//--------------------------------------------------------------------

View file

@ -1,6 +1,6 @@
/** GSWTemplateParserXML.m - <title>GSWeb: Class GSWTemplateParserXML</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Mar 1999
@ -30,6 +30,8 @@
</license>
**/
static const char rcsId[]="$Id$";
#include "GSWeb.h"
#include "GSWTemplateParserXML.h"
#include <libxml/parser.h>
@ -890,7 +892,9 @@ text [Type:XML_TEXT_NODE] [{}] ####
GSXMLNode* currentNode=node;
NSMutableArray* _elements=nil;
NSAutoreleasePool* arp = nil;
BOOL includesComment = NO;
LOGObjectFnStart();
includesComment=[GSWApplication includeCommentsInResponses];
_elements=[NSMutableArray array];
arp=[NSAutoreleasePool new];
while(currentNode)
@ -936,8 +940,11 @@ text [Type:XML_TEXT_NODE] [{}] ####
case XML_COMMENT_NODE:
{
NSDebugMLog0(@"COMMENT");
elem=[GSWHTMLBareString elementWithString:[NSString stringWithFormat:@"<!-- %s -->",[[currentNode content] lossyCString]]];
NSDebugMLLog(@"GSWTemplateParser",@"COMMENT element=%@",elem);
if (includesComment)
{
elem=[GSWHTMLBareString elementWithString:[NSString stringWithFormat:@"<!-- %s -->",[[currentNode content] lossyCString]]];
NSDebugMLLog(@"GSWTemplateParser",@"COMMENT element=%@",elem);
};
};
break;
default:

View file

@ -1,6 +1,6 @@
/** GSWTransactionRecord.m - <title>GSWeb: Class GSWTransactionRecord</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Apr 1999
@ -27,7 +27,7 @@
</license>
**/
static char rcsId[] = "$Id$";
static const char rcsId[] = "$Id$";
#include <GSWeb/GSWeb.h>
@ -46,7 +46,7 @@ static char rcsId[] = "$Id$";
NSString* requestSignature=nil;
[self setResponsePage:aResponsePage];
NSDebugMLLog(@"low",@"responsePage=%@",_responsePage);
contextID=[aContext contextID];//Really from here ?
contextID=[aContext contextID];//Really from here ? Use aContext _requestContextID instead ? //TODO
NSDebugMLLog(@"low",@"contextID=%@",contextID);
senderID=[aContext senderID];
NSDebugMLLog(@"low",@"senderID=%@",senderID);

View file

@ -1,6 +1,6 @@
/** GSWUtils.m - <title>GSWeb: Utilities</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
@ -234,11 +234,11 @@ extern NSData* HexStringToData(NSString* _string);
@interface NSDictionary (SBDictionary)
-(id) objectForKey:(id)key
withDefaultObject:(id)defaultObject;
+(id) dictionaryWithDictionary:(NSDictionary*)dictionary
andDefaultEntriesFromDictionary:(NSDictionary*)dictionaryDefaults;
-(id)dictionaryBySettingObject:(id)object
forKey:(id)key;
-(id)dictionaryByAddingEntriesFromDictionary:(NSDictionary*)dictionary;
+(NSDictionary*)dictionaryWithDictionary:(NSDictionary*)dictionary
andDefaultEntriesFromDictionary:(NSDictionary*)dictionaryDefaults;
-(NSDictionary*)dictionaryBySettingObject:(id)object
forKey:(id)key;
-(NSDictionary*)dictionaryByAddingEntriesFromDictionary:(NSDictionary*)dictionary;
@end
//====================================================================
@ -246,6 +246,8 @@ extern NSData* HexStringToData(NSString* _string);
-(void)setDefaultObject:(id)object
forKey:(id)key;
-(void)addDefaultEntriesFromDictionary:(NSDictionary*)dictionary;
-(NSDictionary*)extractObjectsForKeysWithPrefix:(NSString*)prefix
removePrefix:(BOOL)removePrefix;
@end
//====================================================================

View file

@ -1,12 +1,13 @@
/** GSWUtils.m - <title>GSWeb: Utilities</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
$Revision$
$Date$
$Id$
This file is part of the GNUstep Web Library.
@ -27,7 +28,7 @@
</license>
**/
static char rcsId[] = "$Id$";
static const char rcsId[]="$Id$";
#include <GSWeb/GSWeb.h>
@ -526,6 +527,7 @@ void ValidationExceptionRaiseFn0(const char *func,
NSMutableDictionary* userInfo=nil;
NSArray* frameInfoArray=nil;
LOGObjectFnStart();
NSAssert(frameInfo,@"No frameInfo");
userInfo=[NSMutableDictionary dictionaryWithDictionary:[self userInfo]];
frameInfoArray=[userInfo objectForKey:@"FrameInfo"];
if (frameInfoArray)
@ -1588,7 +1590,8 @@ NSString* GSWGetDefaultDocRoot()
//--------------------------------------------------------------------
NSString* DataToHexString(NSData* data)
{
unsigned int size=[data length];
unsigned int size=0;
size=[data length];
if (size)
{
const unsigned char* pData=(const unsigned char*)[data bytes];
@ -1623,7 +1626,7 @@ NSData* HexStringToData(NSString* string)
if (pString[i*2]>='0' && pString[i*2]<='9')
pData[i]=(pString[i*2]-'0') << 4;
else if (pString[i*2]>='A' && pString[i*2]<='F')
pData[i]=(pString[i*2]-'A') << 4;
pData[i]=(pString[i*2]-'A'+10) << 4;
else
{
NSCAssert(NO,@"Bad hex String");
@ -1631,7 +1634,7 @@ NSData* HexStringToData(NSString* string)
if (pString[i*2+1]>='0' && pString[i*2+1]<='9')
pData[i]=pData[i]|(pString[i*2+1]-'0');
else if (pString[i*2+1]>='A' && pString[i*2+1]<='F')
pData[i]=pData[i]|(pString[i*2+1]-'A');
pData[i]=pData[i]|(pString[i*2+1]-'A'+10);
else
{
NSCAssert(NO,@"Bad hex String");
@ -1658,8 +1661,8 @@ NSData* HexStringToData(NSString* string)
};
//--------------------------------------------------------------------
+(id) dictionaryWithDictionary:(NSDictionary*)dictionary
andDefaultEntriesFromDictionary:(NSDictionary*)dictionaryDefaults
+(NSDictionary*)dictionaryWithDictionary:(NSDictionary*)dictionary
andDefaultEntriesFromDictionary:(NSDictionary*)dictionaryDefaults
{
NSMutableDictionary* dict=nil;
if (dictionary)
@ -1678,8 +1681,8 @@ NSData* HexStringToData(NSString* string)
};
//--------------------------------------------------------------------
-(id)dictionaryBySettingObject:(id)object
forKey:(id)key
-(NSDictionary*)dictionaryBySettingObject:(id)object
forKey:(id)key
{
NSMutableDictionary* dict=[[self mutableCopy]autorelease];
[dict setObject:object
@ -1689,7 +1692,7 @@ NSData* HexStringToData(NSString* string)
};
//--------------------------------------------------------------------
-(id)dictionaryByAddingEntriesFromDictionary:(NSDictionary*)dictionary
-(NSDictionary*)dictionaryByAddingEntriesFromDictionary:(NSDictionary*)dictionary
{
NSMutableDictionary* dict=[[self mutableCopy]autorelease];
[dict addEntriesFromDictionary:dictionary];
@ -1721,6 +1724,40 @@ NSData* HexStringToData(NSString* string)
forKey:key];
};
//--------------------------------------------------------------------
-(NSDictionary*)extractObjectsForKeysWithPrefix:(NSString*)prefix
removePrefix:(BOOL)removePrefix
{
NSMutableDictionary* newDictionary=nil;
NSEnumerator *enumerator = nil;
NSString* key=nil;
NSString* newKey=nil;
id value=nil;
LOGObjectFnStart();
newDictionary=(NSMutableDictionary*)[NSMutableDictionary dictionary];
enumerator = [self keyEnumerator];
while ((key = [enumerator nextObject]))
{
NSDebugMLLog(@"associations",@"key=%@",key);
if ([key hasPrefix:prefix])
{
value=[self objectForKey:key];
NSDebugMLLog(@"associations",@"value=%@",value);
if (removePrefix)
newKey=[key stringByDeletingPrefix:prefix];
else
newKey=key;
[newDictionary setObject:value
forKey:newKey];
[self removeObjectForKey:key];
};
};
newDictionary=[NSDictionary dictionaryWithDictionary:newDictionary];
LOGObjectFnStop();
return newDictionary;
};
@end
@ -1789,7 +1826,7 @@ NSData* HexStringToData(NSString* string)
//--------------------------------------------------------------------
+(id)dictionaryWithArray:(NSArray*)array
onSelector:(SEL)sel
withObject:(id)object
withObject:(id)anObject
{
NSMutableDictionary* dict=[NSMutableDictionary dictionary];
int count=[array count];
@ -1801,7 +1838,7 @@ NSData* HexStringToData(NSString* string)
//TODO optimiser
object=[array objectAtIndex:i];
key=[object performSelector:sel
withObject:object];
withObject:anObject];
NSAssert1(key,@"NSDictionary dictionaryWithArray: no key for object:%@",object);
[dict setObject:object
forKey:key];
@ -2000,8 +2037,8 @@ NSData* HexStringToData(NSString* string)
NSRange current;
current = NSMakeRange (search.location,
found.location-search.location);
NSDebugFLog(@"current=(%u,%u)",current.location,current.length);
tmpData=[self subdataWithRange:current];
NSDebugFLog(@"current=(%u,%u)",current.location,current.length);
tmpData=[self subdataWithRange:current];
[array addObject:tmpData];
search = NSMakeRange (found.location + found.length,
complete.length - found.location - found.length);

View file

@ -1,6 +1,6 @@
/** NSString+HTML.h - <title>GSWeb: NSString / HTML</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
@ -42,6 +42,10 @@
-(NSDictionary*)dictionaryWithSep1:(NSString*)sep1
withSep2:(NSString*)sep2
withOptionUnescape:(BOOL)unescape;
-(NSDictionary*)dictionaryWithSep1:(NSString*)sep1
withSep2:(NSString*)sep2
withOptionUnescape:(BOOL)unescape
forceArray:(BOOL)forceArray;
-(BOOL)ismapCoordx:(int*)x
y:(int*)y;
-(NSString*)stringByEscapingHTMLString;

View file

@ -1,12 +1,13 @@
/** NSString+HTML.m - <title>GSWeb: NSString / HTML</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
$Revision$
$Date$
$Id$
This file is part of the GNUstep Web Library.
@ -27,7 +28,7 @@
</license>
**/
static char rcsId[] = "$Id$";
static const char rcsId[] = "$Id$";
#include <GSWeb/GSWeb.h>
@ -297,13 +298,25 @@ void initHtmlChars()
{
return [self dictionaryWithSep1:@"&"
withSep2:@"="
withOptionUnescape:YES];
withOptionUnescape:YES
forceArray:YES];
};
//--------------------------------------------------------------------
-(NSDictionary*)dictionaryWithSep1:(NSString*)sep1
withSep2:(NSString*)sep2
withOptionUnescape:(BOOL)unescape
{
return [self dictionaryWithSep1:sep1
withSep2:sep2
withOptionUnescape:unescape
forceArray:NO];
};
//--------------------------------------------------------------------
-(NSDictionary*)dictionaryWithSep1:(NSString*)sep1
withSep2:(NSString*)sep2
withOptionUnescape:(BOOL)unescape
forceArray:(BOOL)forceArray// Put value in array even if there's only one value
{
NSMutableDictionary* pDico=nil;
if ([self length]>0)
@ -341,9 +354,19 @@ void initHtmlChars()
if (!value)
value=[NSString string];
if (prevValue)
newValue=[prevValue arrayByAddingObject:value];
{
if (!forceArray || [prevValue isKindOfClass:[NSArray class]])
newValue=[prevValue arrayByAddingObject:value];
else
newValue=[NSArray arrayWithObjects:prevValue,value,nil];
}
else
newValue=[NSArray arrayWithObject:value];
{
if (forceArray)
newValue=[NSArray arrayWithObject:value];
else
newValue=value;
};
[pDico setObject:newValue
forKey: key];
};

View file

@ -1,9 +1,9 @@
/** NSString+Trimming.h - <title>GSWeb: Class NSString with Trimming </title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
Date: Jan 1999
$Revision$
$Date$

View file

@ -1,12 +1,13 @@
/** NSString+Trimming.m - <title>GSWeb: Class NSString with Trimming </title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
$Revision$
$Date$
$Id$
This file is part of the GNUstep Web Library.
@ -27,9 +28,10 @@
</license>
**/
static char rcsId[] = "$Id$";
static const char rcsId[] = "$Id$";
#include <GSWeb/GSWeb.h>
#include <time.h>
//====================================================================
@implementation NSString (SBString)
@ -163,25 +165,33 @@ static char rcsId[] = "$Id$";
{
int i=0;
NSTimeInterval ti=[[NSDate date]timeIntervalSinceReferenceDate];
int size=0;
NSMutableData* data=nil;
void* pData=NULL;
NSString* dataHex=nil;
int intLength=(length/sizeof(int))-sizeof(ti);
if (intLength<0)
intLength=0;
size=sizeof(ti)+intLength*sizeof(int);
data=[NSMutableData dataWithLength:size];
NSString* dataHex=nil;
NSAssert1(length>=sizeof(ti),@"Too short length: %d",length);
data=[NSMutableData dataWithLength:length];
NSAssert(data,@"no data");
pData=[data mutableBytes];
dataHex=nil;
*((NSTimeInterval*)pData)=ti;//TODO: NSSwapHostLongToBig(ti);
NSAssert(pData,@"no pData");
NSDebugMLog(@"pData=%p",pData);
*((NSTimeInterval*)pData)=ti;
pData+=sizeof(ti);
for(i=0;i<intLength;i++)
length-=sizeof(ti);
srand(time(NULL));
for(i=0;i<length;i++)
{
*((int*)pData)=rand(); //TODO: NSSwapHostIntToBig(rand());
pData+=sizeof(int);
*((unsigned char*)pData)=(unsigned char)(256*rand()/(RAND_MAX+1.0));
pData++;
};
NSDebugMLog(@"pData=%p",pData);
dataHex=DataToHexString(data);
NSDebugMLog(@"dataHex %p=%@",dataHex,dataHex);
return dataHex;
};

View file

@ -66,11 +66,15 @@ classname:
;
member:
memberName:IDENT^ { ASSIGN(currentMemberName,[memberName text]); }
memberName:mname { ASSIGN(currentMemberName,([memberName_AST toStringListWithSiblingSeparator:@"" openSeparator:@"" closeSeparator:@""])); }
ASSIGN ( mvalue )
(SEMI)*!
;
mname:
(QUESTIONMARK)? (IDENT)
;
//TODO unescapedString
mvalue:
( assocKeyPath:idref
@ -162,7 +166,7 @@ IDENTREF
PIDENTREF
options { testLiterals = true; }
: POINT (IDENTREF | STRING)
: POINT (IDENTREF | INT | STRING)
;
YES
@ -196,6 +200,9 @@ COLUMN: ':'
ASSIGN: '='
;
QUESTIONMARK: '?'
;
WS:
( ' '
| '\t'

View file

@ -226,6 +226,8 @@ static void GCC_DumpStack(void)
char *pname;
char name[MAX_BUFFER_SIZE];
int number;
write(global_output,
"GCC_DumpStack-001\n", strlen("GCC_DumpStack-001\n"));
for (i = 0; p; i++)
{
@ -315,19 +317,27 @@ static void GCC_DumpStack(void)
}
} /* for */
write(global_output,
"GCC_DumpStack-002\n", strlen("GCC_DumpStack-002\n"));
/* First find out if we are using GNU or vendor nm */
number = 0;
strcpy(buffer, "nm -V 2>/dev/null | grep GNU | wc -l");
write(global_output,
"GCC_DumpStack-002b\n", strlen("GCC_DumpStack-002b\n"));
fd = my_popen(buffer, &pid);
if (SYS_ERROR != fd)
{
write(global_output,
"GCC_DumpStack-002c\n", strlen("GCC_DumpStack-002c\n"));
if (my_getline(fd, buffer, sizeof(buffer)))
{
sscanf(buffer, "%d", &number);
}
my_pclose(fd, pid);
}
write(global_output,
"GCC_DumpStack-002d\n", strlen("GCC_DumpStack-002d\n"));
if (number == 0) /* vendor nm */
{
# if defined(PLATFORM_SOLARIS) || defined(PLATFORM_SCO) || defined(PLATFORM_HPUX)
@ -340,7 +350,11 @@ static void GCC_DumpStack(void)
}
else /* GNU nm */
strcpy(buffer, "nm -B ");
write(global_output,
"GCC_DumpStack-002e\n", strlen("GCC_DumpStack-002e\n"));
strcat(buffer, global_progname);
write(global_output,
"GCC_DumpStack-003\n", strlen("GCC_DumpStack-003\n"));
lowestAddress = ULONG_MAX;
highestAddress = 0;
@ -397,6 +411,8 @@ static void GCC_DumpStack(void)
write(global_output, buffer, strlen(buffer));
}
}
write(global_output,
"GCC_DumpStack-004\n", strlen("GCC_DumpStack-004\n"));
}
#endif
@ -424,10 +440,15 @@ static int DumpStack(char *format, ...)
va_start(args, format);
vsprintf(cmd, format, args);
va_end(args);
//MG
write(global_output,
"EEE\n", strlen("EEE\n"));
fd = my_popen(cmd, &pid);
if (SYS_ERROR != fd)
{
//MG
write(global_output,
"FFF\n", strlen("FFF\n"));
/*
* Wait for the child to exit. This must be done
* to make the debugger attach successfully.
@ -441,9 +462,15 @@ static int DumpStack(char *format, ...)
rc = waitpid(pid, &status, 0);
}
while ((SYS_ERROR == rc) && (EINTR == errno));
//MG
write(global_output,
"GGG\n", strlen("GGG\n"));
if ((WIFEXITED(status)) && (WEXITSTATUS(status) == EXIT_SUCCESS))
{
//MG
write(global_output,
"III\n", strlen("III\n"));
while (my_getline(fd, buf, sizeof(buf)))
{
buffer = buf;
@ -464,8 +491,14 @@ static int DumpStack(char *format, ...)
write(global_output, "\n", strlen("\n"));
}
}
//MG
write(global_output,
"JJJ\n", strlen("JJJ\n"));
my_pclose(fd, pid);
}
//MG
write(global_output,
"HHH\n", strlen("HHH\n"));
return gotSomething;
}
#endif /* PLATFORM_UNIX */
@ -752,6 +785,10 @@ void StackTrace(void)
"GCC_DumpStack\n", strlen("GCC_DumpStack\n"));
GCC_DumpStack();
//MG
write(global_output,
"GCC_DumpStack AAA\n", strlen("GCC_DumpStack AAA\n"));
# endif
write(global_output,