mirror of
https://github.com/gnustep/libs-gsweb.git
synced 2025-02-24 04:01:16 +00:00
* GSWeb.framework/GSWComponentRequestHandler.m:
o call application -createContextForRequest: instead of directGSWContext creation o use session -_contextIDMatchingIDsInContext o use matchingContextID to restore already generated page o fix in -lockedHandleRequest: to pur requestContextID in context git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@17021 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ef1e1f1989
commit
c1ed6ff099
1 changed files with 150 additions and 124 deletions
|
@ -40,6 +40,7 @@ RCS_ID("$Id$")
|
||||||
/** Handle request aRequest and return the response
|
/** Handle request aRequest and return the response
|
||||||
This lock application
|
This lock application
|
||||||
**/
|
**/
|
||||||
|
|
||||||
-(GSWResponse*)handleRequest:(GSWRequest*)aRequest
|
-(GSWResponse*)handleRequest:(GSWRequest*)aRequest
|
||||||
{
|
{
|
||||||
//OK
|
//OK
|
||||||
|
@ -65,6 +66,7 @@ RCS_ID("$Id$")
|
||||||
/** Handle request aRequest and return the response
|
/** Handle request aRequest and return the response
|
||||||
Application should be locked before this
|
Application should be locked before this
|
||||||
**/
|
**/
|
||||||
|
|
||||||
-(GSWResponse*)lockedHandleRequest:(GSWRequest*)aRequest
|
-(GSWResponse*)lockedHandleRequest:(GSWRequest*)aRequest
|
||||||
{
|
{
|
||||||
//OK
|
//OK
|
||||||
|
@ -73,7 +75,6 @@ RCS_ID("$Id$")
|
||||||
GSWContext* aContext=nil;
|
GSWContext* aContext=nil;
|
||||||
GSWResponse* response=nil;
|
GSWResponse* response=nil;
|
||||||
NSDictionary* requestHandlerValues=nil;
|
NSDictionary* requestHandlerValues=nil;
|
||||||
NSString* senderID=nil;
|
|
||||||
BOOL exceptionRaised=NO;
|
BOOL exceptionRaised=NO;
|
||||||
LOGObjectFnStart();
|
LOGObjectFnStart();
|
||||||
NS_DURING
|
NS_DURING
|
||||||
|
@ -99,15 +100,25 @@ RCS_ID("$Id$")
|
||||||
NS_ENDHANDLER;
|
NS_ENDHANDLER;
|
||||||
if (!exceptionRaised)
|
if (!exceptionRaised)
|
||||||
{
|
{
|
||||||
|
NSString* senderID=nil;
|
||||||
|
NSString* requestContextID=nil;
|
||||||
|
|
||||||
NSDebugMLLog(@"requests",@"requestHandlerValues=%@",requestHandlerValues);
|
NSDebugMLLog(@"requests",@"requestHandlerValues=%@",requestHandlerValues);
|
||||||
//statisticsStore=[[GSWApplication application]statisticsStore];
|
//statisticsStore=[[GSWApplication application]statisticsStore];
|
||||||
// NSDebugMLLog(@"requests",@"statisticsStore=%@",statisticsStore);
|
// NSDebugMLLog(@"requests",@"statisticsStore=%@",statisticsStore);
|
||||||
//[statisticsStore _applicationWillHandleComponentActionRequest];
|
//[statisticsStore _applicationWillHandleComponentActionRequest];
|
||||||
aContext=[GSWContext contextWithRequest:aRequest];
|
|
||||||
|
aContext=[[GSWApplication application]createContextForRequest:aRequest];
|
||||||
NSDebugMLLog(@"requests",@"aContext=%@",aContext);
|
NSDebugMLLog(@"requests",@"aContext=%@",aContext);
|
||||||
|
|
||||||
senderID=[requestHandlerValues objectForKey:GSWKey_ElementID[GSWebNamingConv]];
|
senderID=[requestHandlerValues objectForKey:GSWKey_ElementID[GSWebNamingConv]];
|
||||||
NSDebugMLLog(@"requests",@"AA senderID=%@",senderID);
|
NSDebugMLLog(@"requests",@"AA senderID=%@",senderID);
|
||||||
[aContext _setSenderID:senderID];
|
[aContext _setSenderID:senderID];
|
||||||
|
|
||||||
|
requestContextID=[requestHandlerValues objectForKey:GSWKey_ContextID[GSWebNamingConv]];
|
||||||
|
NSDebugMLLog(@"requests",@"AA requestContextID=%@",requestContextID);
|
||||||
|
[aContext _setRequestContextID:requestContextID];
|
||||||
|
|
||||||
[application _setContext:aContext];
|
[application _setContext:aContext];
|
||||||
//====>
|
//====>
|
||||||
NS_DURING
|
NS_DURING
|
||||||
|
@ -358,6 +369,7 @@ RCS_ID("$Id$")
|
||||||
GSWContext* responseContext=nil;
|
GSWContext* responseContext=nil;
|
||||||
GSWComponent* responsePageElement=nil;
|
GSWComponent* responsePageElement=nil;
|
||||||
GSWRequest* responseRequest=nil;
|
GSWRequest* responseRequest=nil;
|
||||||
|
NSString* matchingContextID=nil;
|
||||||
|
|
||||||
LOGObjectFnStart();
|
LOGObjectFnStart();
|
||||||
NSDebugMLLog(@"requests",@"aComponent=%@",aComponent);
|
NSDebugMLLog(@"requests",@"aComponent=%@",aComponent);
|
||||||
|
@ -373,148 +385,162 @@ RCS_ID("$Id$")
|
||||||
|
|
||||||
senderID=[aContext senderID];
|
senderID=[aContext senderID];
|
||||||
NSDebugMLLog(@"requests",@"AA senderID=%@",senderID);
|
NSDebugMLLog(@"requests",@"AA senderID=%@",senderID);
|
||||||
//TODO
|
NSDebugMLLog(@"requests",@"AA request=%@",request);
|
||||||
{
|
|
||||||
GSWContext* matchedContext=[aSession _contextIDMatchingContextID:contextID
|
matchingContextID=[aSession _contextIDMatchingIDsInContext:aContext];
|
||||||
requestSenderID:senderID];
|
NSDebugMLLog(@"requests",@"matchingContextID=%@",matchingContextID);
|
||||||
}
|
|
||||||
httpVersion=[request httpVersion];
|
httpVersion=[request httpVersion];
|
||||||
[response setHTTPVersion:httpVersion];
|
[response setHTTPVersion:httpVersion];
|
||||||
[response setAcceptedEncodings:[request browserAcceptedEncodings]];
|
[response setAcceptedEncodings:[request browserAcceptedEncodings]];
|
||||||
[response setHeader:@"text/html"
|
[response setHeader:@"text/html"
|
||||||
forKey:@"content-type"];
|
forKey:@"content-type"];
|
||||||
[aContext _setResponse:response];
|
[aContext _setResponse:response];
|
||||||
page=[aContext page];
|
|
||||||
if (contextID)//??
|
if (matchingContextID)
|
||||||
{
|
{
|
||||||
hasFormValues=[request _hasFormValues];
|
page = [self lockedRestorePageForContextID:matchingContextID
|
||||||
|
inSession:aSession];
|
||||||
|
[aContext _setPageElement:page];
|
||||||
|
[[GSWApplication application] appendToResponse:response
|
||||||
|
inContext:aContext];
|
||||||
|
NSDebugMLLog(@"requests",@"After appendToResponse [aContext elementID]=%@",
|
||||||
|
[aContext elementID]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[aContext _setPageChanged:NO];
|
page=[aContext page];
|
||||||
isFromClientComponent=[request isFromClientComponent];
|
if (contextID)//??
|
||||||
//??
|
|
||||||
[aContext _setPageReplaced:NO];
|
|
||||||
isFromClientComponent=[request isFromClientComponent];
|
|
||||||
};
|
|
||||||
if (hasFormValues)
|
|
||||||
{
|
|
||||||
NSDebugMLLog(@"requests",@"Before takeValues [aContext elementID]=%@",
|
|
||||||
[aContext elementID]);
|
|
||||||
NSAssert([[aContext elementID] length]==0,
|
|
||||||
@"1 lockedDispatchWithPreparedPage elementID length>0");
|
|
||||||
[[GSWApplication application] takeValuesFromRequest:request
|
|
||||||
inContext:aContext];
|
|
||||||
NSDebugMLLog(@"requests",@"After takeValues[aContext elementID]=%@",
|
|
||||||
[aContext elementID]);
|
|
||||||
if (![[aContext elementID] length]==0)
|
|
||||||
{
|
{
|
||||||
LOGSeriousError0(@"2 lockedDispatchWithPreparedPage elementID length>0");
|
hasFormValues=[request _hasFormValues];
|
||||||
[aContext deleteAllElementIDComponents];//NDFN
|
|
||||||
};
|
|
||||||
[aContext _setPageChanged:NO];//???
|
|
||||||
isFromClientComponent=[request isFromClientComponent];
|
|
||||||
[aContext _setPageReplaced:NO];
|
|
||||||
};
|
|
||||||
if (senderID) //??
|
|
||||||
{
|
|
||||||
BOOL pageChanged=NO;
|
|
||||||
NSException* exception=nil;
|
|
||||||
NSDebugMLLog(@"requests",@"Before invokeAction [aContext elementID]=%@",
|
|
||||||
[aContext elementID]);
|
|
||||||
NSAssert([[aContext elementID] length]==0,
|
|
||||||
@"3 lockedDispatchWithPreparedPage elementID length>0");
|
|
||||||
// Exception catching here ?
|
|
||||||
NS_DURING
|
|
||||||
{
|
|
||||||
responsePage=(GSWComponent*)[[GSWApplication application] invokeActionForRequest:request
|
|
||||||
inContext:aContext];
|
|
||||||
NSDebugMLLog(@"requests",@"After invokeAction [aContext elementID]=%@",[aContext elementID]);
|
|
||||||
NSAssert([[aContext elementID] length]==0,@"4 lockedDispatchWithPreparedPage elementID length>0");
|
|
||||||
}
|
|
||||||
NS_HANDLER
|
|
||||||
{
|
|
||||||
LOGException0(@"exception in invokeActionForRequest");
|
|
||||||
LOGException(@"exception=%@",localException);
|
|
||||||
localException=ExceptionByAddingUserInfoObjectFrameInfo(localException,
|
|
||||||
@"In invokeActionForRequest component=%@ of Class %@",
|
|
||||||
[aComponent name],
|
|
||||||
[aComponent class]);
|
|
||||||
LOGException(@"exception=%@",localException);
|
|
||||||
ASSIGN(exception,localException);
|
|
||||||
if (!responsePage)
|
|
||||||
{
|
|
||||||
errorResponse=[[GSWApplication application] handleException:exception
|
|
||||||
inContext:aContext];
|
|
||||||
};
|
|
||||||
DESTROY(exception);
|
|
||||||
}
|
|
||||||
NS_ENDHANDLER;
|
|
||||||
// [aContext deleteAllElementIDComponents];//NDFN
|
|
||||||
NSDebugMLLog(@"requests",@"responsePage=%@",responsePage);
|
|
||||||
if (errorResponse)
|
|
||||||
{
|
|
||||||
response=errorResponse;
|
|
||||||
responseContext=aContext;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!responsePage)
|
[aContext _setPageChanged:NO];
|
||||||
responsePage=page;
|
isFromClientComponent=[request isFromClientComponent];
|
||||||
|
//??
|
||||||
responseContext=[(GSWComponent*)responsePage context];//So what ?
|
[aContext _setPageReplaced:NO];
|
||||||
NSDebugMLLog(@"requests",@"responseContext=%@",responseContext);
|
isFromClientComponent=[request isFromClientComponent];
|
||||||
[responseContext _setPageReplaced:NO];
|
|
||||||
responsePageElement=(GSWComponent*)[responseContext _pageElement];
|
|
||||||
NSDebugMLLog(@"requests",@"responsePageElement=%@",responsePageElement);
|
|
||||||
pageChanged=(responsePage!=responsePageElement);
|
|
||||||
[responseContext _setPageChanged:pageChanged];//??
|
|
||||||
if (pageChanged)
|
|
||||||
{
|
|
||||||
[responseContext _setPageElement:responsePage];
|
|
||||||
};
|
|
||||||
responseRequest=[responseContext request];//SoWhat ?
|
|
||||||
[responseRequest isFromClientComponent];//SoWhat
|
|
||||||
};
|
};
|
||||||
}
|
if (hasFormValues)
|
||||||
else
|
|
||||||
{
|
|
||||||
responseContext=aContext;
|
|
||||||
responsePageElement=page;
|
|
||||||
responsePage=aComponent;
|
|
||||||
responseRequest=request;
|
|
||||||
};
|
|
||||||
if (!errorResponse)
|
|
||||||
{
|
|
||||||
NS_DURING
|
|
||||||
{
|
{
|
||||||
NSDebugMLLog(@"requests",@"response before appendToResponse=%@",response);
|
NSDebugMLLog(@"requests",@"Before takeValues [aContext elementID]=%@",
|
||||||
NSDebugMLLog(@"requests",@"responseContext=%@",responseContext);
|
|
||||||
NSAssert([[aContext elementID] length]==0,
|
|
||||||
@"5 lockedDispatchWithPreparedPage elementID length>0");
|
|
||||||
NSDebugMLLog(@"requests",@"Before appendToResponse [aContext elementID]=%@",
|
|
||||||
[aContext elementID]);
|
|
||||||
[[GSWApplication application] appendToResponse:response
|
|
||||||
inContext:responseContext];
|
|
||||||
NSDebugMLLog(@"requests",@"After appendToResponse [aContext elementID]=%@",
|
|
||||||
[aContext elementID]);
|
[aContext elementID]);
|
||||||
NSAssert([[aContext elementID] length]==0,
|
NSAssert([[aContext elementID] length]==0,
|
||||||
@"6 lockedDispatchWithPreparedPage elementID length>0");
|
@"1 lockedDispatchWithPreparedPage elementID length>0");
|
||||||
responseRequest=[responseContext request];//SoWhat ?
|
[[GSWApplication application] takeValuesFromRequest:request
|
||||||
//Not used [responseRequest isFromClientComponent];//SoWhat
|
inContext:aContext];
|
||||||
}
|
NSDebugMLLog(@"requests",@"After takeValues[aContext elementID]=%@",
|
||||||
NS_HANDLER
|
[aContext elementID]);
|
||||||
|
if (![[aContext elementID] length]==0)
|
||||||
|
{
|
||||||
|
LOGSeriousError0(@"2 lockedDispatchWithPreparedPage elementID length>0");
|
||||||
|
[aContext deleteAllElementIDComponents];//NDFN
|
||||||
|
};
|
||||||
|
[aContext _setPageChanged:NO];//???
|
||||||
|
isFromClientComponent=[request isFromClientComponent];
|
||||||
|
[aContext _setPageReplaced:NO];
|
||||||
|
};
|
||||||
|
if (senderID) //??
|
||||||
{
|
{
|
||||||
localException=ExceptionByAddingUserInfoObjectFrameInfo(localException,
|
BOOL pageChanged=NO;
|
||||||
@"In appendToResponse page=%@ of Class %@",
|
NSException* exception=nil;
|
||||||
[page name],
|
NSDebugMLLog(@"requests",@"Before invokeAction [aContext elementID]=%@",
|
||||||
[page class]);
|
[aContext elementID]);
|
||||||
LOGException(@"exception=%@",localException);
|
NSAssert([[aContext elementID] length]==0,
|
||||||
NSDebugMLLog(@"requests",@"context=%@",aContext);
|
@"3 lockedDispatchWithPreparedPage elementID length>0");
|
||||||
errorResponse=[[GSWApplication application] handleException:localException
|
// Exception catching here ?
|
||||||
inContext:aContext];
|
NS_DURING
|
||||||
|
{
|
||||||
|
responsePage=(GSWComponent*)[[GSWApplication application] invokeActionForRequest:request
|
||||||
|
inContext:aContext];
|
||||||
|
NSDebugMLLog(@"requests",@"After invokeAction [aContext elementID]=%@",[aContext elementID]);
|
||||||
|
NSAssert([[aContext elementID] length]==0,@"4 lockedDispatchWithPreparedPage elementID length>0");
|
||||||
|
}
|
||||||
|
NS_HANDLER
|
||||||
|
{
|
||||||
|
LOGException0(@"exception in invokeActionForRequest");
|
||||||
|
LOGException(@"exception=%@",localException);
|
||||||
|
localException=ExceptionByAddingUserInfoObjectFrameInfo(localException,
|
||||||
|
@"In invokeActionForRequest component=%@ of Class %@",
|
||||||
|
[aComponent name],
|
||||||
|
[aComponent class]);
|
||||||
|
LOGException(@"exception=%@",localException);
|
||||||
|
ASSIGN(exception,localException);
|
||||||
|
if (!responsePage)
|
||||||
|
{
|
||||||
|
errorResponse=[[GSWApplication application] handleException:exception
|
||||||
|
inContext:aContext];
|
||||||
|
};
|
||||||
|
DESTROY(exception);
|
||||||
|
}
|
||||||
|
NS_ENDHANDLER;
|
||||||
|
// [aContext deleteAllElementIDComponents];//NDFN
|
||||||
|
NSDebugMLLog(@"requests",@"responsePage=%@",responsePage);
|
||||||
|
if (errorResponse)
|
||||||
|
{
|
||||||
|
response=errorResponse;
|
||||||
|
responseContext=aContext;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!responsePage)
|
||||||
|
responsePage=page;
|
||||||
|
|
||||||
|
responseContext=[(GSWComponent*)responsePage context];//So what ?
|
||||||
|
NSDebugMLLog(@"requests",@"responseContext=%@",responseContext);
|
||||||
|
[responseContext _setPageReplaced:NO];
|
||||||
|
responsePageElement=(GSWComponent*)[responseContext _pageElement];
|
||||||
|
NSDebugMLLog(@"requests",@"responsePageElement=%@",responsePageElement);
|
||||||
|
pageChanged=(responsePage!=responsePageElement);
|
||||||
|
[responseContext _setPageChanged:pageChanged];//??
|
||||||
|
if (pageChanged)
|
||||||
|
{
|
||||||
|
[responseContext _setPageElement:responsePage];
|
||||||
|
};
|
||||||
|
responseRequest=[responseContext request];//SoWhat ?
|
||||||
|
[responseRequest isFromClientComponent];//SoWhat
|
||||||
|
};
|
||||||
}
|
}
|
||||||
NS_ENDHANDLER;
|
else
|
||||||
|
{
|
||||||
|
responseContext=aContext;
|
||||||
|
responsePageElement=page;
|
||||||
|
responsePage=aComponent;
|
||||||
|
responseRequest=request;
|
||||||
|
};
|
||||||
|
if (!errorResponse)
|
||||||
|
{
|
||||||
|
NS_DURING
|
||||||
|
{
|
||||||
|
NSDebugMLLog(@"requests",@"response before appendToResponse=%@",response);
|
||||||
|
NSDebugMLLog(@"requests",@"responseContext=%@",responseContext);
|
||||||
|
NSAssert([[aContext elementID] length]==0,
|
||||||
|
@"5 lockedDispatchWithPreparedPage elementID length>0");
|
||||||
|
NSDebugMLLog(@"requests",@"Before appendToResponse [aContext elementID]=%@",
|
||||||
|
[aContext elementID]);
|
||||||
|
[[GSWApplication application] appendToResponse:response
|
||||||
|
inContext:responseContext];
|
||||||
|
NSDebugMLLog(@"requests",@"After appendToResponse [aContext elementID]=%@",
|
||||||
|
[aContext elementID]);
|
||||||
|
NSAssert([[aContext elementID] length]==0,
|
||||||
|
@"6 lockedDispatchWithPreparedPage elementID length>0");
|
||||||
|
responseRequest=[responseContext request];//SoWhat ?
|
||||||
|
//Not used [responseRequest isFromClientComponent];//SoWhat
|
||||||
|
}
|
||||||
|
NS_HANDLER
|
||||||
|
{
|
||||||
|
localException=ExceptionByAddingUserInfoObjectFrameInfo(localException,
|
||||||
|
@"In appendToResponse page=%@ of Class %@",
|
||||||
|
[page name],
|
||||||
|
[page class]);
|
||||||
|
LOGException(@"exception=%@",localException);
|
||||||
|
NSDebugMLLog(@"requests",@"context=%@",aContext);
|
||||||
|
errorResponse=[[GSWApplication application] handleException:localException
|
||||||
|
inContext:aContext];
|
||||||
|
}
|
||||||
|
NS_ENDHANDLER;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
NSDebugMLLog(@"requests",@"response=%@",response);
|
NSDebugMLLog(@"requests",@"response=%@",response);
|
||||||
LOGObjectFnStop();
|
LOGObjectFnStop();
|
||||||
|
|
Loading…
Reference in a new issue