From ee56247d12f32c1784c96e417dcc59f4ab0b13f7 Mon Sep 17 00:00:00 2001 From: Manuel Guesdon Date: Fri, 26 Oct 2001 08:50:52 +0000 Subject: [PATCH] 2001-10-25 Manuel Guesdon Applied patch from Turbocat (www.turbocat.de): GSWPatch_04-JUL_2001.diff except GSWeb.framework/GSWInput.m/.h one (have to verify coherence of it) * GSWAdaptors/common/GSWApp.c/.h: Added GSWAppInfo * GSWAdaptors/common/GSWAppConnectNSSocket.c: Changes on includes * GSWAdaptors/common/GSWLoadBalancing.h: Added parameter to GSWLoadBalancing_Find* * GSWAdaptors/common/GSWLoadBalancing.c: added p_pURLComponents parameter, o management of AppInfo * GSWAdaptors/common/GSWAppRequest.c: managing refused connections * GSWExtensions.framework/GSWStatsPage.gswc/GSWStatsPage.gswd: misspelling correction * GSWExtensions.framework/GSWStatsPage.gswc/GSWStatsPage.html: Various Changes * GSWExtensions.framework/GSWStatsPage.m: changes in login/password validation o -awake added * GSWeb.framework/GSWApplication.m/.h: Manage refusing new sessions * GSWeb.framework/GSWBundle.m: debug traces commented * GSWeb.framework/GSWComponent.m: implementation of ensureAwakeInContext: * GSWeb.framework/GSWAssociation.m: special case for returned value of type GSMutableArray (Why ?) * GSWeb.framework/GSWComponentRequestHandler.m: comments added * GSWeb.framework/GSWDefaultAdaptorThread.m: added debug traces * GSWeb.framework/GSWDirectActionRequestHandler.m: replaced GSWDirectAction by DirectAction * GSWeb.framework/GSWDisplayGroup.m: initialize _baseIndex, o correct misspelled names, o added -description, o use delegate in _changedInEditingContext:, _invalidatedAllObjectsInStore:, o changes in -deleteObjectAtIndex:, * GSWeb.framework/GSWFileUpload.m: different handling of _fileDatasCount, handle bug in omniweb-browser * GSWeb.framework/GSWHyperlink.m: added ensureAwakeInContext: call * GSWeb.framework/GSWImageButton.m: added ensureAwakeInContext: call * GSWeb.framework/GSWPopUpButton.m: o use [response_ appendContentString:_noSelectionStringValue] instead of [response_ appendContentHTMLString:_noSelectionStringValue] o handle no displayString case o use [response_ appendContentString:_displayStringValue] instead of [response_ appendContentHTMLString:_displayStringValue] * GSWeb.framework/GSWConfig.h: set GSWOPTVALUE_AutoOpenInBrowser to NO * GSWeb.framework/GSWElementIDString.m: comment some debug traces * GSWeb.framework/GSWHTMLStaticGroup.m/.h: added support of documentType * GSWeb.framework/GSWHTMLURLValuedElement.m: addeded debug trace * GSWeb.framework/GSWKeyValueAssociation.m: use NSStringFromClass([retValue class]) instead of [retValue class] for log * GSWeb.framework/GSWRequest.m/.h: added -(NSDictionary*)headers; o added test on _contentType in _contentType o autorelease _dict in -uriElements * GSWeb.framework/GSWResponse.m/.h: added -setHeaders: and -headers o Added GSWResponse (GSWResponseRefused) o return self in -generateResponse * GSWeb.framework/GSWServerSessionStore.m/.h: added @interface GSWServerSessionStore (GSWServerSessionStoreInfo) o added refusing session management * GSWeb.framework/GSWSession.m: o in -terminate forces to call removeSessionWithID in GSWServerSessionStore to dealloc it * GSWeb.framework/GSWSessionTimeOutManager.m/.h: replace NSMutableOrderedArray* sessionOrderedTimeOuts; by NSMutableArray* sessionOrderedTimeOuts; o added traces o added GSWSessionTimeOutManager (GSWSessionRefused) * GSWeb.framework/GSWSubmitButton.m: raise exception if no element is returned * GSWeb.framework/GSWTemplateParser.m: added doctype management * GSWeb.framework/GSWUtils.h: added if defined for __NetBSD__ * GSWeb.framework/GSWWOCompatibility.m/.h: added WOGenericContainer, WOImageButton, WOHyperlink * GSWeb.framework/attach.m: added if defined for __NetBSD__ * GSWeb.framework/stacktrace.m: added if defined for __NetBSD__ * GSWeb.framework/GSWTemplateParserXML.m: traces commented o test XML node content before adding it * GSWeb.framework/NSObject+IVarAccess+PerformSel.m o changes in -getIVarNamed: and in setIVarNamed:withValue: (use of sel+imp, tests on parameters) * GSWAdaptors/common/GSWHTTPResponse.c: change in GSWHTTPResponse_GetResponse() o debug traces removed git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@11251 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 69 +++ GSWAdaptors/common/GSWApp.c | 87 +++ GSWAdaptors/common/GSWApp.h | 16 + GSWAdaptors/common/GSWAppConnectNSSocket.c | 8 +- GSWAdaptors/common/GSWAppRequest.c | 36 +- GSWAdaptors/common/GSWHTTPResponse.c | 6 + GSWAdaptors/common/GSWLoadBalancing.c | 74 ++- GSWAdaptors/common/GSWLoadBalancing.h | 4 +- .../GSWStatsPage.gswc/GSWStatsPage.gswd | 2 +- .../GSWStatsPage.gswc/GSWStatsPage.html | 554 +++++++++--------- GSWExtensions.framework/GSWStatsPage.m | 47 +- GSWeb.framework/GSWApplication.h | 1 + GSWeb.framework/GSWApplication.m | 129 +++- GSWeb.framework/GSWAssociation.m | 57 +- GSWeb.framework/GSWBundle.m | 12 +- GSWeb.framework/GSWComponent.m | 13 +- GSWeb.framework/GSWComponentRequestHandler.m | 6 +- GSWeb.framework/GSWConfig.h | 2 +- GSWeb.framework/GSWDefaultAdaptorThread.m | 5 +- .../GSWDirectActionRequestHandler.m | 11 +- GSWeb.framework/GSWDisplayGroup.m | 126 +++- GSWeb.framework/GSWElementIDString.m | 6 +- GSWeb.framework/GSWFileUpload.m | 16 + GSWeb.framework/GSWHTMLStaticGroup.h | 9 + GSWeb.framework/GSWHTMLStaticGroup.m | 33 ++ GSWeb.framework/GSWHTMLURLValuedElement.m | 1 + GSWeb.framework/GSWHyperlink.m | 11 +- GSWeb.framework/GSWImageButton.m | 16 + GSWeb.framework/GSWKeyValueAssociation.m | 4 +- GSWeb.framework/GSWPopUpButton.m | 12 +- GSWeb.framework/GSWRequest.h | 1 + GSWeb.framework/GSWRequest.m | 25 +- GSWeb.framework/GSWResponse.h | 14 + GSWeb.framework/GSWResponse.m | 94 ++- GSWeb.framework/GSWServerSessionStore.h | 6 + GSWeb.framework/GSWServerSessionStore.m | 23 + GSWeb.framework/GSWSession.m | 1 + GSWeb.framework/GSWSessionStore.h | 1 - GSWeb.framework/GSWSessionStore.m | 6 - GSWeb.framework/GSWSessionTimeOutManager.h | 11 +- GSWeb.framework/GSWSessionTimeOutManager.m | 224 ++++++- GSWeb.framework/GSWSubmitButton.m | 22 + GSWeb.framework/GSWTemplateParser.m | 17 + GSWeb.framework/GSWTemplateParserXML.m | 47 +- GSWeb.framework/GSWUtils.h | 2 +- GSWeb.framework/GSWWOCompatibility.h | 9 + GSWeb.framework/GSWWOCompatibility.m | 9 + .../NSObject+IVarAccess+PerformSel.m | 51 +- GSWeb.framework/attach.m | 2 +- GSWeb.framework/stacktrace.m | 2 +- README | 3 + 51 files changed, 1505 insertions(+), 438 deletions(-) diff --git a/ChangeLog b/ChangeLog index fa6b718..c4a2457 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,72 @@ +2001-10-25 Manuel Guesdon + Applied patch from Turbocat (www.turbocat.de): GSWPatch_04-JUL_2001.diff + except GSWeb.framework/GSWInput.m/.h one (have to verify coherence of it) + + * GSWAdaptors/common/GSWApp.c/.h: Added GSWAppInfo + * GSWAdaptors/common/GSWAppConnectNSSocket.c: Changes on includes + * GSWAdaptors/common/GSWLoadBalancing.h: Added parameter to GSWLoadBalancing_Find* + * GSWAdaptors/common/GSWLoadBalancing.c: added p_pURLComponents parameter, + o management of AppInfo + * GSWAdaptors/common/GSWAppRequest.c: managing refused connections + * GSWExtensions.framework/GSWStatsPage.gswc/GSWStatsPage.gswd: misspelling correction + * GSWExtensions.framework/GSWStatsPage.gswc/GSWStatsPage.html: Various Changes + * GSWExtensions.framework/GSWStatsPage.m: changes in login/password validation + o -awake added + * GSWeb.framework/GSWApplication.m/.h: Manage refusing new sessions + * GSWeb.framework/GSWBundle.m: debug traces commented + * GSWeb.framework/GSWComponent.m: implementation of ensureAwakeInContext: + * GSWeb.framework/GSWAssociation.m: special case for returned value of type GSMutableArray (Why ?) + * GSWeb.framework/GSWComponentRequestHandler.m: comments added + * GSWeb.framework/GSWDefaultAdaptorThread.m: added debug traces + * GSWeb.framework/GSWDirectActionRequestHandler.m: replaced GSWDirectAction by DirectAction + * GSWeb.framework/GSWDisplayGroup.m: initialize _baseIndex, + o correct misspelled names, + o added -description, + o use delegate in _changedInEditingContext:, _invalidatedAllObjectsInStore:, + o changes in -deleteObjectAtIndex:, + * GSWeb.framework/GSWFileUpload.m: different handling of _fileDatasCount, + handle bug in omniweb-browser + * GSWeb.framework/GSWHyperlink.m: added ensureAwakeInContext: call + * GSWeb.framework/GSWImageButton.m: added ensureAwakeInContext: call + * GSWeb.framework/GSWPopUpButton.m: + o use [response_ appendContentString:_noSelectionStringValue] instead of + [response_ appendContentHTMLString:_noSelectionStringValue] + o handle no displayString case + o use [response_ appendContentString:_displayStringValue] instead of + [response_ appendContentHTMLString:_displayStringValue] + * GSWeb.framework/GSWConfig.h: set GSWOPTVALUE_AutoOpenInBrowser to NO + * GSWeb.framework/GSWElementIDString.m: comment some debug traces + * GSWeb.framework/GSWHTMLStaticGroup.m/.h: added support of documentType + * GSWeb.framework/GSWHTMLURLValuedElement.m: addeded debug trace + * GSWeb.framework/GSWKeyValueAssociation.m: use NSStringFromClass([retValue class]) + instead of [retValue class] for log + * GSWeb.framework/GSWRequest.m/.h: added -(NSDictionary*)headers; + o added test on _contentType in _contentType + o autorelease _dict in -uriElements + * GSWeb.framework/GSWResponse.m/.h: added -setHeaders: and -headers + o Added GSWResponse (GSWResponseRefused) + o return self in -generateResponse + * GSWeb.framework/GSWServerSessionStore.m/.h: added @interface GSWServerSessionStore (GSWServerSessionStoreInfo) + o added refusing session management + * GSWeb.framework/GSWSession.m: + o in -terminate forces to call removeSessionWithID in GSWServerSessionStore to dealloc it + * GSWeb.framework/GSWSessionTimeOutManager.m/.h: replace NSMutableOrderedArray* sessionOrderedTimeOuts; + by NSMutableArray* sessionOrderedTimeOuts; + o added traces + o added GSWSessionTimeOutManager (GSWSessionRefused) + * GSWeb.framework/GSWSubmitButton.m: raise exception if no element is returned + * GSWeb.framework/GSWTemplateParser.m: added doctype management + * GSWeb.framework/GSWUtils.h: added if defined for __NetBSD__ + * GSWeb.framework/GSWWOCompatibility.m/.h: added WOGenericContainer, WOImageButton, WOHyperlink + * GSWeb.framework/attach.m: added if defined for __NetBSD__ + * GSWeb.framework/stacktrace.m: added if defined for __NetBSD__ + * GSWeb.framework/GSWTemplateParserXML.m: traces commented + o test XML node content before adding it + * GSWeb.framework/NSObject+IVarAccess+PerformSel.m + o changes in -getIVarNamed: and in setIVarNamed:withValue: (use of sel+imp, tests on parameters) + * GSWAdaptors/common/GSWHTTPResponse.c: change in GSWHTTPResponse_GetResponse() + o debug traces removed + 2001-08-28 Adam Fedor * GSWExtensions.framework/Makefile.preamble: Add GSWeb framework diff --git a/GSWAdaptors/common/GSWApp.c b/GSWAdaptors/common/GSWApp.c index 7772109..b8006eb 100644 --- a/GSWAdaptors/common/GSWApp.c +++ b/GSWAdaptors/common/GSWApp.c @@ -191,4 +191,91 @@ void GSWAppInstance_InternClear(GSWDictElem* p_pElem,void* p_pData) pInstance->fValid=FALSE; }; +//-------------------------------------------------------------------- +//-------------------------------------------------------------------- + +void GSWAppInfo_Init() +{ + if (_gswAppInfoDict == NULL) { + _gswAppInfoDict = GSWDict_New(50); // allows 50 different instances of apps + } +} + +//-------------------------------------------------------------------- +char* GSWAppInfo_MakeDictKeyName(char* pszName, int iInstance) +{ + char *name = NULL; + + if (name = calloc(1,30)) { + if (pszName) { + strcpy(name, pszName); + } + sprintf(name + strlen(name), "%d", iInstance); + + } + return name; +} + +//-------------------------------------------------------------------- +GSWAppInfo* GSWAppInfo_Find(char* pszName, int iInstance) +{ + char *name; + GSWAppInfo* newInfo = NULL; + + if (_gswAppInfoDict == NULL) { + GSWAppInfo_Init(); + return NULL; + } + + name = GSWAppInfo_MakeDictKeyName(pszName, iInstance); + if (name) { + newInfo = GSWDict_ValueForKey(_gswAppInfoDict, name); + free(name); name = NULL; + } + + return newInfo; +} + +//-------------------------------------------------------------------- +void GSWAppInfo_Add(GSWAppInfo* appInfoDict, CONST char* keyName) +{ + if (appInfoDict) { + GSWDict_Add(_gswAppInfoDict, keyName, appInfoDict, TRUE); + } +} + +//-------------------------------------------------------------------- +void GSWAppInfo_Set(char* pszName, int iInstance, BOOL isRefused) +{ + char *name; + GSWAppInfo* newInfo = GSWAppInfo_Find(pszName, iInstance); + time_t curTime = (time_t)0; + BOOL addDict = FALSE; + + if (newInfo == NULL) { + newInfo=(GSWAppInfo*)calloc(1,sizeof(GSWAppInfo)); + addDict = TRUE; + } + + if (newInfo && (name = GSWAppInfo_MakeDictKeyName(pszName, iInstance) )) { + newInfo->isRefused = isRefused; + time(&curTime); + newInfo->timeNextRetryTime = curTime + 10; // + 10 sec + + if (addDict == TRUE) { + GSWAppInfo_Add(newInfo, name); + } + free(name); name = NULL; + } else { + if (newInfo) { + free(newInfo); newInfo = NULL; + } + } +} + +//-------------------------------------------------------------------- +void GSWAppInfo_Remove(GSWAppInfo* _appInfo) +{ +} + diff --git a/GSWAdaptors/common/GSWApp.h b/GSWAdaptors/common/GSWApp.h index a0056d9..54768a3 100644 --- a/GSWAdaptors/common/GSWApp.h +++ b/GSWAdaptors/common/GSWApp.h @@ -58,5 +58,21 @@ GSWAppInstance* GSWAppInstance_New(GSWApp* p_pApp); void GSWAppInstance_Free(GSWAppInstance* p_pInstance); BOOL GSWAppInstance_FreeIFND(GSWAppInstance* p_pInstance); +//--------------------------------------------------------------------- +typedef struct _GSWAppInfo +{ + BOOL isRefused; + time_t timeNextRetryTime; // next try to look, if it is not refused +} GSWAppInfo; + +static GSWDict* _gswAppInfoDict = NULL; + +void GSWAppInfo_Init(); +GSWAppInfo* GSWAppInfo_Find(char* pszName, int iInstance); +void GSWAppInfo_Add(GSWAppInfo* appInfoDict, CONST char* keyName); +void GSWAppInfo_Set(char* pszName, int iInstance, BOOL isRefused); +void GSWAppInfo_Remove(GSWAppInfo* _appInfo); + + #endif // _GSWApp_h__ diff --git a/GSWAdaptors/common/GSWAppConnectNSSocket.c b/GSWAdaptors/common/GSWAppConnectNSSocket.c index 5b347c0..13e06d6 100644 --- a/GSWAdaptors/common/GSWAppConnectNSSocket.c +++ b/GSWAdaptors/common/GSWAppConnectNSSocket.c @@ -25,12 +25,18 @@ #include #include #include +#include +#include +#include +#include +#include #include "config.h" #include "GSWUtil.h" #include "GSWDict.h" #include "GSWURLUtil.h" -#include "GSWAppRequest.h" +//#include "GSWAppRequest.h" +#include "GSWAppRequestStruct.h" #include "GSWAppConnect.h" typedef SYS_NETFD AppConnectNSSocketHandle; diff --git a/GSWAdaptors/common/GSWAppRequest.c b/GSWAdaptors/common/GSWAppRequest.c index 35765c8..c142f19 100644 --- a/GSWAdaptors/common/GSWAppRequest.c +++ b/GSWAdaptors/common/GSWAppRequest.c @@ -45,6 +45,20 @@ unsigned long glbRequestsNb = 0; unsigned long glbResponsesNb = 0; +/* + +HTTP/1.0 302 Apple WebObjects +x-webobjects-refusenewsessions: 900 +Location: /cgi-bin/WebObjects/cancer.woa +x-webobjects-refusing-redirection: YES +x-webobjects-loadaverage: 1 +Content-Length: 152 + +Sorry, your request could not immediately be processed. Please try this URL: /cgi-bin/WebObjects/cancer.woa +Connection closed by foreign host. + +*/ + //-------------------------------------------------------------------- GSWHTTPResponse* GSWAppRequest_SendAppRequestToApp(GSWHTTPRequest** p_ppHTTPRequest, GSWURLComponents* p_pURLComponents, @@ -57,12 +71,15 @@ GSWHTTPResponse* GSWAppRequest_SendAppRequestToApp(GSWHTTPRequest** p_ppHTTPRequ BOOL fAppNotResponding=FALSE; int iAttemptsRemaining=APP_CONNECT_RETRIES_NB; AppConnectHandle hConnect=NULL; + char *appName = NULL; + int appInstance = 0; + GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWAppRequest_SendAppRequestToApp"); if (p_pAppRequest->iInstance>0) //-1 or 0 mean any instance - fAppFound = GSWLoadBalancing_FindInstance(p_pAppRequest,p_pLogServerData); + fAppFound = GSWLoadBalancing_FindInstance(p_pAppRequest,p_pLogServerData, p_pURLComponents); else - fAppFound = GSWLoadBalancing_FindApp(p_pAppRequest,p_pLogServerData); + fAppFound = GSWLoadBalancing_FindApp(p_pAppRequest,p_pLogServerData, p_pURLComponents); if (!fAppFound) { @@ -112,6 +129,9 @@ GSWHTTPResponse* GSWAppRequest_SendAppRequestToApp(GSWHTTPRequest** p_ppHTTPRequ "Request %s sent, awaiting response", (*p_ppHTTPRequest)->pszRequest); + appName = strdup(p_pAppRequest->pszName); + appInstance = p_pAppRequest->iInstance; + p_pAppRequest->pRequest = NULL; pHTTPResponse = GSWHTTPResponse_GetResponse(hConnect,p_pLogServerData); p_pAppRequest->pResponse = pHTTPResponse; @@ -125,11 +145,21 @@ GSWHTTPResponse* GSWAppRequest_SendAppRequestToApp(GSWHTTPRequest** p_ppHTTPRequ glbResponsesNb++; if (pHTTPResponse) { + char *value = GSWDict_ValueForKey(pHTTPResponse->pHeaders,"x-gsweb-refusing-redirection"); + if (value && (strncmp(value,"YES",3)==0)) { + // refuseNewSessions == YES in app + GSWLog(GSW_INFO,p_pLogServerData,"### This app (%s / %d) is refusing all new sessions ###", appName, appInstance); + GSWAppInfo_Set(appName, appInstance, TRUE); + } + GSWLog(GSW_INFO,p_pLogServerData, "received: %d %s", pHTTPResponse->uStatus, pHTTPResponse->pszStatusMessage); }; + if (appName) { + free(appName); appName = NULL; + } }; } else @@ -149,7 +179,7 @@ GSWHTTPResponse* GSWAppRequest_SendAppRequestToApp(GSWHTTPRequest** p_ppHTTPRequ { GSWLoadBalancing_MarkNotRespondingApp(p_pAppRequest,p_pLogServerData); if (iAttemptsRemaining-->0) - fAppFound=GSWLoadBalancing_FindApp(p_pAppRequest,p_pLogServerData); + fAppFound=GSWLoadBalancing_FindApp(p_pAppRequest,p_pLogServerData, p_pURLComponents); }; }; }; diff --git a/GSWAdaptors/common/GSWHTTPResponse.c b/GSWAdaptors/common/GSWHTTPResponse.c index 303184a..0679192 100644 --- a/GSWAdaptors/common/GSWHTTPResponse.c +++ b/GSWAdaptors/common/GSWHTTPResponse.c @@ -246,18 +246,23 @@ GSWHTTPResponse* GSWHTTPResponse_GetResponse(AppConnectHandle p_socket,void* p_p #endif if (iReceivedCount!= pHTTPResponse->uContentLength) { +pHTTPResponse->pContent = pszBuffer;//TODO: Verify this (Turbocat patch) + GSWLog(GSW_ERROR,p_pLogServerData, "Content received doesn't equal to ContentLength. Too bad, same player shoot again !"); + free(pszBuffer); pszBuffer=NULL; GSWHTTPResponse_Free(pHTTPResponse,p_pLogServerData); pHTTPResponse=NULL; pHTTPResponse = GSWHTTPResponse_BuildErrorResponse(NULL,"Invalid Response",p_pLogServerData); + } else pHTTPResponse->pContent = pszBuffer; } #ifdef DEBUG +/* if (pHTTPResponse->pContent) { char szTraceBuffer[pHTTPResponse->uContentLength+1]; @@ -271,6 +276,7 @@ GSWHTTPResponse* GSWHTTPResponse_GetResponse(AppConnectHandle p_socket,void* p_p szTraceBuffer); // GSWLog(GSW_INFO,p_pLogServerData,"\nEND\n"); }; +*/ #endif }; GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWHTTPResponse_GetResponse"); diff --git a/GSWAdaptors/common/GSWLoadBalancing.c b/GSWAdaptors/common/GSWLoadBalancing.c index 3a37066..0e86bda 100644 --- a/GSWAdaptors/common/GSWLoadBalancing.c +++ b/GSWAdaptors/common/GSWLoadBalancing.c @@ -42,10 +42,11 @@ #include "GSWHTTPHeaders.h" #include "GSWLoadBalancing.h" #include "GSWLock.h" +#include "GSWApp.h" //-------------------------------------------------------------------- BOOL GSWLoadBalancing_FindApp(GSWAppRequest* p_pAppRequest, - void* p_pLogServerData) + void* p_pLogServerData, GSWURLComponents* p_pURLComponents) { BOOL fFound=FALSE; GSWApp* pApp=NULL; @@ -93,14 +94,32 @@ BOOL GSWLoadBalancing_FindApp(GSWAppRequest* p_pAppRequest, }; if (pAppInstance->timeNextRetryTime==0 && pAppInstance->fValid) { - fFound = TRUE; - strcpy(p_pAppRequest->pszName,pApp->pszName); - p_pAppRequest->iInstance = pAppInstance->iInstance; - p_pAppRequest->pszHost = pAppInstance->pszHostName; - p_pAppRequest->iPort = pAppInstance->iPort; - p_pAppRequest->eType = EAppType_LoadBalanced; - p_pAppRequest->pAppInstance = pAppInstance; - pAppInstance->uOpenedRequestsNb++; + BOOL okay = TRUE; + // check if refused, time to try again ? + if (p_pURLComponents->stRequestHandlerKey.iLength==0 || p_pURLComponents->stRequestHandlerKey.pszStart==NULL) { + GSWAppInfo *thisAppInfo = GSWAppInfo_Find(p_pAppRequest->pszName, pAppInstance->iInstance); + if (thisAppInfo && thisAppInfo->isRefused) { + time_t actTime = (time_t)0; + // this instance refuses new sessions + time(&actTime); + if (actTime > thisAppInfo->timeNextRetryTime) { + thisAppInfo->isRefused = FALSE; // try it again + } else { + okay = FALSE; // try an other instance + } + } + } + + if (okay == TRUE) { + fFound = TRUE; + strcpy(p_pAppRequest->pszName,pApp->pszName); + p_pAppRequest->iInstance = pAppInstance->iInstance; + p_pAppRequest->pszHost = pAppInstance->pszHostName; + p_pAppRequest->iPort = pAppInstance->iPort; + p_pAppRequest->eType = EAppType_LoadBalanced; + p_pAppRequest->pAppInstance = pAppInstance; + pAppInstance->uOpenedRequestsNb++; + } }; }; }; @@ -122,7 +141,7 @@ BOOL GSWLoadBalancing_FindApp(GSWAppRequest* p_pAppRequest, }; //-------------------------------------------------------------------- -BOOL GSWLoadBalancing_FindInstance(GSWAppRequest *p_pAppRequest,void* p_pLogServerData) +BOOL GSWLoadBalancing_FindInstance(GSWAppRequest *p_pAppRequest,void* p_pLogServerData, GSWURLComponents* p_pURLComponents) { BOOL fFound=FALSE; GSWApp* pApp=NULL; @@ -142,14 +161,33 @@ BOOL GSWLoadBalancing_FindInstance(GSWAppRequest *p_pAppRequest,void* p_pLogServ GSWLog(GSW_DEBUG,p_pLogServerData,"Instance Found"); if (pAppInstance->fValid) { - fFound=TRUE; - p_pAppRequest->iInstance = pAppInstance->iInstance; - p_pAppRequest->pszHost = pAppInstance->pszHostName; - p_pAppRequest->iPort = pAppInstance->iPort; - p_pAppRequest->eType = EAppType_LoadBalanced; - p_pAppRequest->pAppInstance = pAppInstance; - pAppInstance->uOpenedRequestsNb++; - GSWLog(GSW_DEBUG,p_pLogServerData,"Instance is valid"); + BOOL okay = TRUE; + // check if refused, time to try again ? + if (p_pURLComponents->stRequestHandlerKey.iLength==0 || p_pURLComponents->stRequestHandlerKey.pszStart==NULL) { + GSWAppInfo *thisAppInfo = GSWAppInfo_Find(p_pAppRequest->pszName, pAppInstance->iInstance); + if (thisAppInfo && thisAppInfo->isRefused) { + time_t actTime = (time_t)0; + // this instance refuses new sessions + time(&actTime); + if (actTime > thisAppInfo->timeNextRetryTime) { + thisAppInfo->isRefused = FALSE; // try it again + } else { + okay = FALSE; // try an other instance + } + } + } + + if (okay == TRUE) { + + fFound=TRUE; + p_pAppRequest->iInstance = pAppInstance->iInstance; + p_pAppRequest->pszHost = pAppInstance->pszHostName; + p_pAppRequest->iPort = pAppInstance->iPort; + p_pAppRequest->eType = EAppType_LoadBalanced; + p_pAppRequest->pAppInstance = pAppInstance; + pAppInstance->uOpenedRequestsNb++; + GSWLog(GSW_DEBUG,p_pLogServerData,"Instance is valid"); + } } else { diff --git a/GSWAdaptors/common/GSWLoadBalancing.h b/GSWAdaptors/common/GSWLoadBalancing.h index f409925..d5c33d2 100644 --- a/GSWAdaptors/common/GSWLoadBalancing.h +++ b/GSWAdaptors/common/GSWLoadBalancing.h @@ -24,8 +24,8 @@ #ifndef _GSWLoadBalancing_h__ #define _GSWLoadBalancing_h__ -BOOL GSWLoadBalancing_FindApp(GSWAppRequest* p_pAppRequest,void* p_pLogServerData); -BOOL GSWLoadBalancing_FindInstance(GSWAppRequest* p_pAppRequest,void* p_pLogServerData); +BOOL GSWLoadBalancing_FindApp(GSWAppRequest* p_pAppRequest,void* p_pLogServerData, GSWURLComponents* p_pURLComponents); +BOOL GSWLoadBalancing_FindInstance(GSWAppRequest* p_pAppRequest,void* p_pLogServerData, GSWURLComponents* p_pURLComponents); void GSWLoadBalancing_MarkNotRespondingApp(GSWAppRequest* p_pAppRequest,void* p_pLogServerData); void GSWLoadBalancing_StartAppRequest(GSWAppRequest* p_pAppRequest,void* p_pLogServerData); void GSWLoadBalancing_StopAppRequest(GSWAppRequest* p_pAppRequest,void* p_pLogServerData); diff --git a/GSWExtensions.framework/GSWStatsPage.gswc/GSWStatsPage.gswd b/GSWExtensions.framework/GSWStatsPage.gswc/GSWStatsPage.gswd index 13947d2..6d65ecd 100644 --- a/GSWExtensions.framework/GSWStatsPage.gswc/GSWStatsPage.gswd +++ b/GSWExtensions.framework/GSWStatsPage.gswc/GSWStatsPage.gswd @@ -182,7 +182,7 @@ MovingAvgTransactionTime: GSWString value = transactions."Moving Avg. Transaction Time"; } -PASSGSWRD: GSWPasswordField +PASSWORD: GSWPasswordField { WIDTH = 12; value = password; diff --git a/GSWExtensions.framework/GSWStatsPage.gswc/GSWStatsPage.html b/GSWExtensions.framework/GSWStatsPage.gswc/GSWStatsPage.html index 0f5df60..bca5637 100644 --- a/GSWExtensions.framework/GSWStatsPage.gswc/GSWStatsPage.html +++ b/GSWExtensions.framework/GSWStatsPage.gswc/GSWStatsPage.html @@ -1,288 +1,272 @@ - + + - - -
-

This Request Requires A User Login

-
- -
-
- - - - - - - - -
-

Statistics For - - - # - - - - On Host - - -

-
- -

- -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Application Statistics -
  TransactionsAverage Transaction
Time
Average Idle
Time
Moving Average*
Transaction Time
Moving Average*
Idle Time
Overall
Component ActionsNA   NA
Direct ActionsNA   NA
Started at - -
Running time - -
- - * The sample size for Moving Averages is transactions. - -
- -
-
- - - - - - - - - - - - - - - -
Sessions Statistics
- - - -
Peak Concurrent Sessions at
-
-
-
-
- -
- - - - - - - - - - -
Memory Usage (bytes) -
- - - -
-
- - - - - - - - - - -
Avg. Memory Usage Per Session (bytes) -
- - - - -
-
-
- -
- - -Response Descriptions For Last User : -
-
- - - - - - -
- -
-
-

- -
- - - - - - - - - - - - - - - - - - -
- Component Action Statistics -
NameServedMinAvgMax
-
- -
- -
- - - - - - - - - - - - - - - - - - -
- Direct Action Statistics -
NameServedMinAvgMax
-
- -
- -
- - - - - - - - - - - - - - -
- Detailed Statistics -
Response DescriptionPercent Of TotalServed
-
- -
-
-Statistics Details Saved In Common Log Format In File
- -
-
- -
-
- - \ No newline at end of file + +
+

This Request Requires A User Login

+
+ + + +
+ + + + + + + + + + + +
+ User + + +
+ Password + + +
+ +
+
+ +
+
+ + + + + + +
+

Statistics For + + + # + + On Host + +

+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Application Statistics +
+   + TransactionsAverage Transaction
+ Time
Average Idle
+ Time
Moving Average*
+ Transaction Time
Moving Average*
+ Idle Time
Overall
Component ActionsNA +   + NA
Direct ActionsNA +   + NA
Started at + +
Running time + +
+ * The sample size for Moving Averages is transactions. +
+
+
+ + + + + + + + + + + + + + + +
Sessions Statistics
+ + + +
Peak Concurrent Sessions at
+ +
+
+
+
+ + +
+ + + + + + + + + + +
Memory Usage (bytes) +
+ + + +
+ + + + + + + + + + +
Avg. Memory Usage Per Session (bytes) +
+ + + + +
+
+
+ + Response Descriptions For Last User :
+
+ + + + + + +
+ +
+
+
+
+
+ + + + + + + + + + + + + + + + + + +
Component Action Statistics
NameServedMinAvgMax
+
+
+
+ + + + + + + + + + + + + + + + + + +
Direct Action Statistics
NameServedMinAvgMax
+
+
+
+ + + + + + + + + + + + + + +
Detailed Statistics
Response DescriptionPercent Of TotalServed
+
+ +
+
+ Statistics Details Saved In Common Log Format In File
+
+
+ +
+ \ No newline at end of file diff --git a/GSWExtensions.framework/GSWStatsPage.m b/GSWExtensions.framework/GSWStatsPage.m index d2c38df..2f3d92b 100644 --- a/GSWExtensions.framework/GSWStatsPage.m +++ b/GSWExtensions.framework/GSWStatsPage.m @@ -30,7 +30,8 @@ GSWStatisticsStore* _statisticsStore = [[self application] statisticsStore]; if (_statisticsStore) { - [_statisticsStore validateLogin:password]; + //[_statisticsStore validateLogin:password]; + [[self session] _allowToViewStatistics]; }; return self; }; @@ -40,6 +41,50 @@ return [[NSHost currentHost] name]; } +- (void) awake +{ +/* + NSString* tmpKey; + NSString* tmpItem; + + NSDictionary* detailsDict; + NSDictionary* pagesDict; + NSDictionary* directActionsDict; + NSDictionary* sessionMemoryDict; + NSDictionary* transactions; + NSDictionary* statsDict; + NSDictionary* memoryDict; + NSArray* sessionStats; + NSMutableDictionary* sessionsDict; + NSNumber* maxPageCount; + NSNumber* maxActionCount; + NSDate* maxSessionsDate; + NSString* userName; + NSString* password; + +*/ +NSLog(@"detailsDict"); +NSLog([detailsDict description]); +NSLog(@"pagesDict"); +NSLog([pagesDict description]); +NSLog(@"directActionsDict"); +NSLog([directActionsDict description]); +NSLog(@"sessionMemoryDict"); +NSLog([sessionMemoryDict description]); + +NSLog(@"transactions"); +/*NSLog(transactions); +NSLog(@"statsDict"); +NSLog(statsDict); +NSLog(@"memoryDict"); +NSLog(memoryDict); +NSLog(@"sessionStats"); +NSLog(sessionStats); +NSLog(@"sessionsDict"); +NSLog(sessionsDict); +*/ +} + -(id)instance { id _instance=nil; diff --git a/GSWeb.framework/GSWApplication.h b/GSWeb.framework/GSWApplication.h index 5c35f62..86800da 100644 --- a/GSWeb.framework/GSWApplication.h +++ b/GSWeb.framework/GSWApplication.h @@ -75,6 +75,7 @@ extern BOOL WOStrictFlag; BOOL terminating; BOOL dynamicLoadingEnabled; BOOL printsHTMLParserDiagnostics; + BOOL refusingNewSessions; BOOL shouldDieWhenRefusing; BOOL refusingNewClients; BOOL refuseThisRequest; diff --git a/GSWeb.framework/GSWApplication.m b/GSWeb.framework/GSWApplication.m index 980ec6a..60aa0fa 100644 --- a/GSWeb.framework/GSWApplication.m +++ b/GSWeb.framework/GSWApplication.m @@ -467,6 +467,8 @@ int GSWApplicationMain(NSString* applicationClassName, permanentPageCacheSize=30; pageRecreationEnabled=YES; pageRefreshOnBacktrackEnabled=YES; + refusingNewSessions = NO; + minimumActiveSessionsCount = 0; // 0 is default dynamicLoadingEnabled=YES; printsHTMLParserDiagnostics=YES; [[self class] _setApplication:self]; @@ -511,6 +513,7 @@ int GSWApplicationMain(NSString* applicationClassName, name:GSWNotification__SessionDidTimeOutNotification[GSWebNamingConv] object:nil]; NSDebugMLLog0(@"low",@"init: addObserver called"); + LOGObjectFnStop(); return self; }; @@ -901,6 +904,8 @@ int GSWApplicationMain(NSString* applicationClassName, forKey:_resourceRequestHandlerKey]; [self registerRequestHandler:_directActionRequestHandler forKey:_directActionRequestHandlerKey]; + [self registerRequestHandler:_directActionRequestHandler + forKey: GSWDirectActionRequestHandlerKey[GSWebNamingConvInversed]]; NSDebugMLLog(@"low",@"requestHandlers:%@",requestHandlers); [self setDefaultRequestHandler:_componentRequestHandler]; LOGObjectFnStop(); @@ -1307,10 +1312,12 @@ int GSWApplicationMain(NSString* applicationClassName, NS_DURING { [self lockedDecrementActiveSessionCount]; +/* if ([self isRefusingNewSessions]) { //TODO }; +*/ } NS_HANDLER { @@ -1358,20 +1365,22 @@ int GSWApplicationMain(NSString* applicationClassName, [self lock]; NS_DURING { +/* if ([self isRefusingNewSessions]) { //TODO erreur ? NSDebugMLLog0(@"low",@"isRefusingNewSessions!"); } else - { +*/ +// { [self lockedIncrementActiveSessionCount]; _session=[self createSessionForRequest:[context_ request]]; NSDebugMLLog(@"sessions",@"_session:%@",_session); NSDebugMLLog(@"sessions",@"_session ID:%@",[_session sessionID]); [context_ _setSession:_session]; [_session awakeInContext:context_]; - }; +// }; } NS_HANDLER { @@ -2302,6 +2311,61 @@ int GSWApplicationMain(NSString* applicationClassName, //==================================================================== @implementation GSWApplication (GSWRequestHandling) + +-(GSWResponse*)checkAppIfRefused:(GSWRequest*)request_ +{ + NSDictionary* _requestHandlerValues=nil; + GSWResponse* _response=nil; + NSString* _sessionID=nil; + BOOL _refuseRequest = NO; + + LOGObjectFnStart(); + + NS_DURING + { + NSLog(@"Application : checkAppIfRefused"); + NSLog(@"Application : allSessionIDs = %@", [sessionStore allSessionIDs]); + _requestHandlerValues=[GSWComponentRequestHandler _requestHandlerValuesForRequest:request_]; + if (_requestHandlerValues) { + NSLog(@"Application : _requestHandlerValues is set"); + + _sessionID=[_requestHandlerValues objectForKey:GSWKey_SessionID[GSWebNamingConv]]; + if (!_sessionID) { + NSLog(@"Application : _sessionID is nil"); + + if ([self isRefusingNewSessions] == YES) { + _refuseRequest = YES; + } + } else { + NSLog(@"Application : _sessionID found : %@", _sessionID); + NSLog(@"Application : allSessionIDs = %@", [sessionStore allSessionIDs]); + // check for existing session ID + if ([sessionStore containsSessionID:_sessionID] == NO) { + NSLog(@"Application : sessionStore does not contain _sessionID"); + if ([self isRefusingNewSessions] == YES) { + _refuseRequest = YES; + } + } + } + if (_refuseRequest == YES) { + NSLog(@"Application : _refuseRequest == YES ,generate Response"); + // generate response, to refuse the request + _response=[GSWResponse generateRefusingResponseInContext:nil forRequest:request_]; + if (_response) { + [_response _finalizeInContext:nil]; //DO Call _finalizeInContext: ! + } + } + } + } + NS_HANDLER + + NS_ENDHANDLER; + + LOGObjectFnStop(); + + return _response; +} + -(GSWResponse*)dispatchRequest:(GSWRequest*)request_ { //OK @@ -2313,29 +2377,34 @@ int GSWApplicationMain(NSString* applicationClassName, GSWApplicationDebugSetChange(); [self unlock]; #endif - NSDebugMLLog(@"requests",@"request_=%@",request_); - _requestHandler=[self handlerForRequest:request_]; - NSDebugMLLog(@"requests",@"_requestHandler=%@",_requestHandler); - if (!_requestHandler) - _requestHandler=[self defaultRequestHandler]; - NSDebugMLLog(@"requests",@"_requestHandler=%@",_requestHandler); - if (!_requestHandler) - { - NSDebugMLLog0(@"low",@"GSWApplication dispatchRequest: no request handler"); - //TODO error - } - else - { - NSDebugMLLog(@"requests",@"sessionStore=%@",sessionStore); - _response=[_requestHandler handleRequest:request_]; - NSDebugMLLog(@"requests",@"sessionStore=%@",sessionStore); - [self _resetCache]; - NSDebugMLLog(@"requests",@"sessionStore=%@",sessionStore); - }; - if (!_response) - { - //TODO RESPONSE_PB - }; + + _response = [self checkAppIfRefused:request_]; + if (_response == nil) { + + NSDebugMLLog(@"requests",@"request_=%@",request_); + _requestHandler=[self handlerForRequest:request_]; + NSDebugMLLog(@"requests",@"_requestHandler=%@",_requestHandler); + if (!_requestHandler) + _requestHandler=[self defaultRequestHandler]; + NSDebugMLLog(@"requests",@"_requestHandler=%@",_requestHandler); + if (!_requestHandler) + { + NSDebugMLLog0(@"low",@"GSWApplication dispatchRequest: no request handler"); + //TODO error + } + else + { + NSDebugMLLog(@"requests",@"sessionStore=%@",sessionStore); + _response=[_requestHandler handleRequest:request_]; + NSDebugMLLog(@"requests",@"sessionStore=%@",sessionStore); + [self _resetCache]; + NSDebugMLLog(@"requests",@"sessionStore=%@",sessionStore); + }; + if (!_response) + { + //TODO RESPONSE_PB + } + } LOGObjectFnStop(); return _response; }; @@ -3287,7 +3356,8 @@ int GSWApplicationMain(NSString* applicationClassName, //TODO return (Vv12@0:4i8) -(void)setMinimumActiveSessionsCount:(int)count_ { - LOGObjectFnNotImplemented(); //TODOFN + //LOGObjectFnNotImplemented(); //TODOFN + minimumActiveSessionsCount = count_; }; //-------------------------------------------------------------------- @@ -3301,8 +3371,8 @@ int GSWApplicationMain(NSString* applicationClassName, //isRefusingNewSessions -(BOOL)isRefusingNewSessions { - LOGObjectFnNotImplemented(); //TODOFN - return NO; + //LOGObjectFnNotImplemented(); //TODOFN + return refusingNewSessions; }; //-------------------------------------------------------------------- @@ -3310,7 +3380,8 @@ int GSWApplicationMain(NSString* applicationClassName, //TODO return: (Vv9@0:4c8) -(void)refuseNewSessions:(BOOL)flag { - LOGObjectFnNotImplemented(); //TODOFN + refusingNewSessions = flag; + //LOGObjectFnNotImplemented(); //TODOFN }; //-------------------------------------------------------------------- diff --git a/GSWeb.framework/GSWAssociation.m b/GSWeb.framework/GSWAssociation.m index c226288..0d3da47 100644 --- a/GSWeb.framework/GSWAssociation.m +++ b/GSWeb.framework/GSWAssociation.m @@ -25,6 +25,7 @@ static char rcsId[] = "$Id$"; #include #include +#include static NSDictionary* localMinMaxDictionary=nil; static NSMutableDictionary* associationsHandlerClasses=nil; @@ -610,6 +611,9 @@ static NSMutableArray* associationsLogsHandlerClasses=nil; { _part=[keys objectAtIndex:0]; [keys removeObjectAtIndex:0]; + if (retValue) { + NSDebugMLLog(@"associations",@"object_get_class_name(retValue object)=%s", object_get_class_name(retValue)); + } NSDebugMLLog(@"associations",@"_part=%@",_part); _handlerClass=[associationsHandlerClasses objectForKey:_part]; NSDebugMLLog(@"associations",@"_handlerClass=%@",_handlerClass); @@ -651,8 +655,49 @@ static NSMutableArray* associationsLogsHandlerClasses=nil; } else { + BOOL skipping = NO; NS_DURING - retValue=[retValue getIVarNamed:_part]; +/* + //NSLog(@"#getIVarNamed"); + if (retValue) { + //NSLog(@"class retValue before getIVarNamed : %s", object_get_class_name(retValue)); + //NSLog(@"description retValue : %@", [retValue description]); + } + + if ((retValue) && (strstr(object_get_class_name(retValue),"GSMutableArray") != NULL)) { + + int counter; + if ([_part isEqual:@"count"]) { + SEL sel=0; + NSMethodSignature *sig ; + + NSLog(@"### retValue class is GSMutableArray (%@)", NSStringFromClass([retValue class])); + sel = NSSelectorFromString(_part); + NSLog(@"### selector = %d", (int)sel); + NSLog(@"### %@", NSStringFromSelector(sel)); + if ([retValue respondsToSelector: sel] == NO) { + NSLog(@"### GSMutableArray does not respond to '%@'", _part); + } else { + NSLog(@"### GSMutableArray responds to '%@'", _part); + } + sig = [retValue methodSignatureForSelector: sel]; + NSLog(@"### [sig numberOfArguments] = %d", [sig numberOfArguments]); + + counter = [retValue count]; + NSLog(@"### count = %d", counter); + skipping = YES; + //retValue = [NSNumber numberWithInt:counter]; + } + } + + //if (!skipping) +*/ + retValue=[retValue getIVarNamed:_part]; +/* + if (retValue) { + NSLog(@"class retValue after getIVarNamed : %s", object_get_class_name(retValue)); + } +*/ NS_HANDLER NSLog(@"Attempt to get %@/%@ raised an exception (%@)",[retValue class],_part,localException); localException = [localException exceptionByAddingToUserInfoKey:@"Invalid Ivars/Methods" format:@"-[%@ %@]",[retValue class],_part]; @@ -663,7 +708,11 @@ static NSMutableArray* associationsLogsHandlerClasses=nil; retValue=nil; }; }; +if (retValue) { NSDebugMLLog(@"associations",@"retValue=%@",retValue); +} else { + NSLog(@"retValue=nil"); +} LOGClassFnStop(); return retValue; }; @@ -677,6 +726,7 @@ static NSMutableArray* associationsLogsHandlerClasses=nil; NSDebugMLLog(@"associations",@"GSWAssociation: setValue:%@",value_); NSDebugMLLog(@"associations",@"value_ class:%@",[value_ class]); NSDebugMLLog(@"associations",@"value_ String class:%@",NSStringFromClass([value_ class])); + NSDebugMLLog(@"associations",@"object_ String class:%@",NSStringFromClass([object_ class])); if (keyPath_) { NSMutableArray* keys=[[keyPath_ componentsSeparatedByString:@"."] mutableCopy]; @@ -705,6 +755,7 @@ static NSMutableArray* associationsLogsHandlerClasses=nil; if ([_part isEqualToString:GSASK_Class]) { Class _class=Nil; +NSLog(@"in GSASK_Class"); NSAssert2([keys count]>0,@"No class name for handler %@ in %@", GSASK_Class, keyPath_); @@ -721,8 +772,10 @@ static NSMutableArray* associationsLogsHandlerClasses=nil; else _object=nil; } - else + else { +//NSLog(@"before called getIVarNamed with _part = %@",_part); _object=[_object getIVarNamed:_part]; + } } else { diff --git a/GSWeb.framework/GSWBundle.m b/GSWeb.framework/GSWBundle.m index f584ef2..a76a602 100644 --- a/GSWeb.framework/GSWBundle.m +++ b/GSWeb.framework/GSWBundle.m @@ -372,24 +372,24 @@ objectForReference:(NSString*)keyPath NSDictionary* variables=nil; NSEnumerator* variablesEnum=nil; id variableName=nil; - NSDebugMLLog(@"bundles",@"archive_:%@",archive_); + //NSDebugMLLog(@"bundles",@"archive_:%@",archive_); unarchiver=[[[EOKeyValueUnarchiver alloc] initWithDictionary:archive_] autorelease]; - NSDebugMLLog(@"bundles",@"unarchiver:%@",unarchiver); + //NSDebugMLLog(@"bundles",@"unarchiver:%@",unarchiver); bundleDelegate=[[[GSWBundleUnarchiverDelegate alloc] initWithObject:object_] autorelease]; - NSDebugMLLog(@"bundles",@"bundleDelegate:%@",bundleDelegate); + //NSDebugMLLog(@"bundles",@"bundleDelegate:%@",bundleDelegate); [unarchiver setDelegate:bundleDelegate]; - NSDebugMLLog(@"bundles",@"decodevar"); + //NSDebugMLLog(@"bundles",@"decodevar"); variables=[unarchiver decodeObjectForKey:@"variables"]; - NSDebugMLLog(@"bundles",@"variables:%@",variables); + //NSDebugMLLog(@"bundles",@"variables:%@",variables); [unarchiver finishInitializationOfObjects]; [unarchiver awakeObjects]; variablesEnum=[variables keyEnumerator]; while ((variableName = [variablesEnum nextObject])) { id variableValue=[variables objectForKey:variableName]; - NSDebugMLLog(@"bundles",@"variableName:%@ variableValue:%@",variableName,variableValue); + //NSDebugMLLog(@"bundles",@"variableName:%@ variableValue:%@",variableName,variableValue); [object_ takeValue:variableValue forKey:variableName]; }; diff --git a/GSWeb.framework/GSWComponent.m b/GSWeb.framework/GSWComponent.m index e558ca4..114fb32 100644 --- a/GSWeb.framework/GSWComponent.m +++ b/GSWeb.framework/GSWComponent.m @@ -1125,7 +1125,18 @@ associationsKeys:(NSArray*)_associationsKeys //-------------------------------------------------------------------- -(void)ensureAwakeInContext:(GSWContext*)context_ { - LOGObjectFnNotImplemented(); //TODOFN + //LOGObjectFnNotImplemented(); //TODOFN + LOGObjectFnStart(); + if (![self context]) { + NSDebugMLLog(@"gswcomponents",@"component sleeps, we awake it = %@",self); + [self awakeInContext:context_]; + } else { + if ([self context] != context_) { + NSDebugMLLog(@"gswcomponents",@"component is already awaken, but has not the current context, we awake it twice with current context = %@",self); + [self awakeInContext:context_]; + } + } + LOGObjectFnStop(); }; //-------------------------------------------------------------------- diff --git a/GSWeb.framework/GSWComponentRequestHandler.m b/GSWeb.framework/GSWComponentRequestHandler.m index d2bab9f..415e3e9 100644 --- a/GSWeb.framework/GSWComponentRequestHandler.m +++ b/GSWeb.framework/GSWComponentRequestHandler.m @@ -168,11 +168,15 @@ static char rcsId[] = "$Id$"; inContext:_context]; if (!_session) { + // check for refuseNewSessions _errorResponse=[_application handleSessionRestorationErrorInContext:_context]; }; } else - _session=[_application _initializeSessionInContext:_context]; + { + // check for refuseNewSessions + _session=[_application _initializeSessionInContext:_context]; + } } NS_HANDLER { diff --git a/GSWeb.framework/GSWConfig.h b/GSWeb.framework/GSWConfig.h index 4d91f36..9dedd4d 100644 --- a/GSWeb.framework/GSWConfig.h +++ b/GSWeb.framework/GSWConfig.h @@ -34,7 +34,7 @@ #define GSWEB_DEFAULT_HTML_PARSER_CLASS_NAME @"GSWTemplateParserXMLHTML" #define GSWOPTVALUE_ApplicationBaseURL_WO @"/WebObjects" #define GSWOPTVALUE_ApplicationBaseURL_GSWEB @"/GSWeb" -#define GSWOPTVALUE_AutoOpenInBrowser @"YES" +#define GSWOPTVALUE_AutoOpenInBrowser @"NO" #define GSWOPTVALUE_CGIAdaptorURL_WO @"/cgi/WebObjects" #define GSWOPTVALUE_CGIAdaptorURL_GSWEB @"/cgi/GSWeb" //or @"http://host.com/cgi/GSWeb" diff --git a/GSWeb.framework/GSWDefaultAdaptorThread.m b/GSWeb.framework/GSWDefaultAdaptorThread.m index cc8b0f8..94e15ce 100644 --- a/GSWeb.framework/GSWDefaultAdaptorThread.m +++ b/GSWeb.framework/GSWDefaultAdaptorThread.m @@ -594,15 +594,16 @@ static char rcsId[] = "$Id$"; NSDebugMLLog(@"low",@"empty:%@",empty); // [responseData appendData:[cl dataUsingEncoding:NSASCIIStringEncoding]]; [responseData appendData:[empty dataUsingEncoding:NSASCIIStringEncoding]]; - + [stream writeData:responseData]; if ([[response content] length]>0) { [responseData setLength:[[response content] length]]; [responseData setData:[response content]]; - + NSDebugMLLog(@"low",@"[response content]:%@",[response content]); NSDebugMLLog(@"low",@"[[response content] length]=%d",[[response content] length]); + NSDebugMLLog(@"[[response content] length]=%d",[[response content] length]); NSDebugMLLog(@"low",@"Response content String NSASCIIStringEncoding:%@",[[[NSString alloc] initWithData:[response content] encoding:NSASCIIStringEncoding] autorelease]); diff --git a/GSWeb.framework/GSWDirectActionRequestHandler.m b/GSWeb.framework/GSWDirectActionRequestHandler.m index b9f8296..df4b9c7 100644 --- a/GSWeb.framework/GSWDirectActionRequestHandler.m +++ b/GSWeb.framework/GSWDirectActionRequestHandler.m @@ -37,7 +37,7 @@ static char rcsId[] = "$Id$"; GSWApplication* _application=nil; LOGObjectFnStart(); _application=[GSWApplication application]; - if ([_application isRefusingNewSessions]) + if (0/*[_application isRefusingNewSessions]*/) { //TODO } @@ -61,20 +61,21 @@ static char rcsId[] = "$Id$"; { case 0: _actionName=@"default"; - _className=@"GSWDirectAction"; + _className=@"DirectAction"; break; case 1: { NSString* _tmpActionName=[NSString stringWithFormat:@"%@Action", [_requestHandlerPathArray objectAtIndex:0]]; SEL _tmpActionSel=NSSelectorFromString(_tmpActionName); + Class _class = NSClassFromString(@"DirectAction"); NSDebugMLLog(@"requests",@"_tmpActionName=%@",_tmpActionName); - if (_tmpActionSel) + if (_tmpActionSel && _class) { - if ([GSWDirectAction instancesRespondToSelector:_tmpActionSel]) + if ([_class instancesRespondToSelector:_tmpActionSel]) { _actionName=[_requestHandlerPathArray objectAtIndex:0]; - _className=@"GSWDirectAction"; + _className=@"DirectAction"; }; }; if (!_actionName) diff --git a/GSWeb.framework/GSWDisplayGroup.m b/GSWeb.framework/GSWDisplayGroup.m index ed5f060..e6fd6a6 100644 --- a/GSWeb.framework/GSWDisplayGroup.m +++ b/GSWeb.framework/GSWDisplayGroup.m @@ -51,6 +51,7 @@ static char rcsId[] = "$Id$"; _queryBindings = [[NSMutableDictionary alloc] initWithCapacity:8]; // _selection = 1; //???? + _batchIndex = 1; [[NSNotificationCenter defaultCenter] addObserver:self @@ -100,7 +101,7 @@ Description: */ if ((self=[self init])) { - LOGObjectFnStop(); + LOGObjectFnStart(); [self setNumberOfObjectsPerBatch: [unarchiver decodeIntForKey:@"numberOfObjectsPerBatch"]]; [self setFetchesOnLoad: @@ -114,7 +115,7 @@ Description: //Don't call setDataSource: because we're not ready ! ASSIGN(_dataSource,[unarchiver decodeObjectForKey:@"dataSource"]); [self setSortOrderings: - [unarchiver decodeObjectForKey:@"sortOrderings"]]; + [unarchiver decodeObjectForKey:@"sortOrdering"]]; [self setQualifier: [unarchiver decodeObjectForKey:@"qualifier"]]; [self setDefaultStringMatchFormat: @@ -128,6 +129,39 @@ Description: return self; }; +-(NSString*)description +{ + NSString* _dscr=nil; + GSWLogAssertGood(self); + NSDebugMLLog(@"gswdisplaygroup",@"GSWDisplayGroup description Self=%p",self); + _dscr=[NSString stringWithFormat:@"<%s %p - \n", + object_get_class_name(self), + (void*)self]; + + _dscr=[_dscr stringByAppendingFormat:@"numberOfObjectsPerBatch:[%d]\n", + _numberOfObjectsPerBatch]; + _dscr=[_dscr stringByAppendingFormat:@"fetchesOnLoad:[%s]\n", + _flags.autoFetch ? "YES" : "NO"]; + _dscr=[_dscr stringByAppendingFormat:@"validatesChangesImmediately:[%s]\n", + _flags.validateImmediately ? "YES" : "NO"]; + _dscr=[_dscr stringByAppendingFormat:@"selectsFirstObjectAfterFetch:[%s]\n", + _flags.selectFirstObject ? "YES" : "NO"]; + _dscr=[_dscr stringByAppendingFormat:@"localKeys:[%@]\n", + _localKeys]; + _dscr=[_dscr stringByAppendingFormat:@"dataSource:[%@]\n", + _dataSource]; + _dscr=[_dscr stringByAppendingFormat:@"sortOrdering:[%@]\n", + _sortOrdering]; + _dscr=[_dscr stringByAppendingFormat:@"qualifier:[%@]\n", + _qualifier]; + _dscr=[_dscr stringByAppendingFormat:@"formatForLikeQualifier:[%@]\n", + _defaultStringMatchFormat]; + _dscr=[_dscr stringByAppendingFormat:@"insertedObjectDefaultValues:[%@]\n", + _insertedObjectDefaultValues]; + + return _dscr; +}; + -(void)awakeFromKeyValueUnarchiver:(EOKeyValueUnarchiver*)unarchiver { @@ -136,6 +170,8 @@ Description: [unarchiver ensureObjectAwake:_dataSource]; if ([self fetchesOnLoad]) { + NSLog(@"***** awakeFromKeyValueUnarchiver in GSWDisplayGroup is called *****"); + [self fetch]; // [self fetch];//?? NO: fetch "each time it is loaded in web browser" }; LOGObjectFnStop(); @@ -147,6 +183,7 @@ Description: LOGObjectFnStart(); [self _setUpForNewDataSource]; //Finished ? + LOGObjectFnStop(); }; @@ -301,7 +338,7 @@ Description: LOGObjectFnStart(); if(_delegateRespondsTo.shouldRedisplay == YES) - redisplay = [self displayGroup:self + redisplay = [delegate displayGroup:self shouldRedisplayForEditingContextChangeNotification:notification]; if(redisplay == YES) @@ -315,7 +352,7 @@ Description: LOGObjectFnStart(); if(_delegateRespondsTo.shouldRefetchObjects == YES) - refetch = [self displayGroup:self + refetch = [delegate displayGroup:self shouldRefetchForInvalidatedAllObjectsNotification: notification]; @@ -554,17 +591,36 @@ Description: object = [_allObjects objectAtIndex:index]; if(_delegateRespondsTo.shouldDeleteObject == YES) - delete = [delegate displayGroup:self - shouldDeleteObject:object]; + delete = [delegate displayGroup:self shouldDeleteObject:object]; if(delete) { - [_dataSource deleteObject:object]; + NS_DURING + { + [_dataSource deleteObject:object]; + + [_displayedObjects removeObjectIdenticalTo:object]; + [_allObjects removeObjectIdenticalTo:object]; - if(_delegateRespondsTo.didDeleteObject == YES) - [delegate displayGroup:self - didDeleteObject:object]; + if(_delegateRespondsTo.didDeleteObject == YES) + [delegate displayGroup:self didDeleteObject:object]; + } + NS_HANDLER + { + NSLog(@"GSWDisplayGroup (deleteObjectAtIndex:) Can't delete object at index : %d", index); + NSLog(@"object : %@", object); + NSLog(@"Exception : %@ %@ Name:%@ Reason:%@\n", + localException, + [localException description], + [localException name], + [localException reason]); + delete = NO; + } + NS_ENDHANDLER; }; + + [self clearSelection]; + LOGObjectFnStop(); return delete; } @@ -592,17 +648,37 @@ Description: } if (result) { - enumerator = [_selectedObjects objectEnumerator]; - while((object = [enumerator nextObject])) - { - [_dataSource deleteObject:object]; + NS_DURING + { + enumerator = [_selectedObjects objectEnumerator]; + while((object = [enumerator nextObject])) + { + [_dataSource deleteObject:object]; + + [_displayedObjects removeObjectIdenticalTo:object]; + [_allObjects removeObjectIdenticalTo:object]; - if(_delegateRespondsTo.didDeleteObject == YES) - [delegate displayGroup:self - didDeleteObject:object]; - } + if(_delegateRespondsTo.didDeleteObject == YES) + [delegate displayGroup:self + didDeleteObject:object]; + } + } + NS_HANDLER + { + NSLog(@"GSWDisplayGroup (deleteSelection:) Can't delete object"); + NSLog(@"object : %@", object); + NSLog(@"Exception : %@ %@ Name:%@ Reason:%@\n", + localException, + [localException description], + [localException name], + [localException reason]); + delete = NO; + } + NS_ENDHANDLER; }; + [self clearSelection]; + LOGObjectFnStop(); return result; } @@ -757,16 +833,11 @@ Description: if(_delegateRespondsTo.shouldFetchObjects == YES) fetch = [delegate displayGroupShouldFetch:self]; - NSDebugMLog(@"fetch=%d",(int)fetch); - if(fetch) { NSArray *objects=nil; - NSDebugMLog(@"_dataSource=%@",_dataSource); - objects = [_dataSource fetchObjects]; - NSDebugMLog(@"objects=%@",objects); [self setObjectArray:objects]; if(_delegateRespondsTo.didFetchObjects == YES) @@ -875,7 +946,7 @@ Description: if(!count) index = 0; - if(count <= index) + if((count <= index) && count>0) index = count - 1; [self insertObjectAtIndex:index]; @@ -1422,18 +1493,23 @@ Description: [_displayedObjects removeAllObjects]; batchCount = [self batchCount]; + NSLog(@"setCurrentBatchIndex : [self batchCount] = %d", [self batchCount]); if(index_ > batchCount) index_ = 1; num = [_allObjects count]; + NSLog(@"setCurrentBatchIndex : [_allObjects count] = %d", [_allObjects count]); if(_numberOfObjectsPerBatch && _numberOfObjectsPerBatch < num) num = _numberOfObjectsPerBatch; if(num) { + NSLog(@"setCurrentBatchIndex : index_ = %d", index_); + NSLog(@"setCurrentBatchIndex : num = %d", num); + for( i = (index_-1) * num; - i < index_ * num; + ((i < index_ * num) && (i < [_allObjects count])); i++) [_displayedObjects addObject:[_allObjects objectAtIndex:i]]; diff --git a/GSWeb.framework/GSWElementIDString.m b/GSWeb.framework/GSWElementIDString.m index a9925de..fa6694f 100644 --- a/GSWeb.framework/GSWElementIDString.m +++ b/GSWeb.framework/GSWElementIDString.m @@ -108,11 +108,11 @@ static char rcsId[] = "$Id$"; LOGObjectFnStart(); GSWLogAssertGood(self); GSWLogAssertGood(_string); - GSWLogC("_string deallocate"); + //GSWLogC("_string deallocate"); DESTROY(_string); - GSWLogC("_string deallocated"); + //GSWLogC("_string deallocated"); [super dealloc]; - GSWLogC("GSWElementIDString end of dealloc"); + //GSWLogC("GSWElementIDString end of dealloc"); }; -(void)getCString:(char*)buffer diff --git a/GSWeb.framework/GSWFileUpload.m b/GSWeb.framework/GSWFileUpload.m index ad1e0ae..101cb06 100644 --- a/GSWeb.framework/GSWFileUpload.m +++ b/GSWeb.framework/GSWFileUpload.m @@ -125,12 +125,16 @@ static char rcsId[] = "$Id$"; _fileDatas=[request_ formValuesForKey:_nameInContext]; NSDebugMLLog(@"gswdync",@"_value=%@",_fileDatas); _fileDatasCount=[_fileDatas count]; +/* if (_fileDatasCount!=1) { ExceptionRaise(@"GSWFileUpload", @"GSWFileUpload: File Data Nb != 1 :%d", _fileDatasCount); }; +*/ + if (_fileDatasCount==1) { + _data=[_fileDatas objectAtIndex:0]; if (_data) { @@ -150,10 +154,14 @@ static char rcsId[] = "$Id$"; } else { + NSLog(@"content type request : %@",[request_ _contentType]); + NSLog(@"data class = %@",NSStringFromClass([_data class])); + /*if (![_data isMemberOfClass:[NSString class]]) { ExceptionRaise(@"GSWFileUpload", @"GSWFileUpload: bad data :%@", _data); _data=nil; + }*/ }; }; } @@ -173,6 +181,14 @@ static char rcsId[] = "$Id$"; inComponent:_component]; [data setValue:_data inComponent:_component]; + } else { + // bug in omniweb-browser if you click cancel in FileOpenPanel, it transmits incorrect datas + + [filepath setValue:nil + inComponent:_component]; + [data setValue:nil + inComponent:_component]; + } } NS_HANDLER { diff --git a/GSWeb.framework/GSWHTMLStaticGroup.h b/GSWeb.framework/GSWHTMLStaticGroup.h index 54b0640..24feb07 100644 --- a/GSWeb.framework/GSWHTMLStaticGroup.h +++ b/GSWeb.framework/GSWHTMLStaticGroup.h @@ -28,7 +28,16 @@ //==================================================================== @interface GSWHTMLStaticGroup: GSWHTMLStaticElement +{ + NSString* _documentTypeString; +} -(id)initWithContentElements:(NSArray*)elements_; +-(void)setDocumentTypeString:(NSString *)documentType_; + +-(void)appendToResponse:(GSWResponse*)response_ + inContext:(GSWContext*)context_; + +-(void)dealloc; @end diff --git a/GSWeb.framework/GSWHTMLStaticGroup.m b/GSWeb.framework/GSWHTMLStaticGroup.m index af5948a..bda9559 100644 --- a/GSWeb.framework/GSWHTMLStaticGroup.m +++ b/GSWeb.framework/GSWHTMLStaticGroup.m @@ -44,4 +44,37 @@ static char rcsId[] = "$Id$"; return self; }; +//-------------------------------------------------------------------- +-(void)setDocumentTypeString:(NSString *)documentType_ +{ + [_documentTypeString release]; + _documentTypeString = [documentType_ retain]; +} + +//-------------------------------------------------------------------- +-(void)appendToResponse:(GSWResponse*)response_ + inContext:(GSWContext*)context_ +{ + if (_documentTypeString) + { + NSStringEncoding _encoding=[response_ contentEncoding]; + + NSDebugMLLog(@"gswdync",@"added _documentTypeString = %@", _documentTypeString); + + [response_ appendContentData:[_documentTypeString + dataUsingEncoding:_encoding]]; + }; + + [super appendToResponse:response_ inContext:context_]; +}; + +//-------------------------------------------------------------------- +-(void)dealloc +{ + [_documentTypeString release]; + + [super dealloc]; +} + + @end diff --git a/GSWeb.framework/GSWHTMLURLValuedElement.m b/GSWeb.framework/GSWHTMLURLValuedElement.m index 17452ef..f67b441 100644 --- a/GSWeb.framework/GSWHTMLURLValuedElement.m +++ b/GSWeb.framework/GSWHTMLURLValuedElement.m @@ -327,6 +327,7 @@ static char rcsId[] = "$Id$"; } else if (filename) { + NSDebugMLLog(@"gswdync",@"_url = %@",_url); [response_ appendContentString:_url]; } else diff --git a/GSWeb.framework/GSWHyperlink.m b/GSWeb.framework/GSWHyperlink.m index 130bb9c..e277932 100644 --- a/GSWeb.framework/GSWHyperlink.m +++ b/GSWeb.framework/GSWHyperlink.m @@ -563,7 +563,16 @@ static char rcsId[] = "$Id$"; if (![_element isKindOfClass:[GSWComponent class]]) //TODO GSWComponent or Element ? { ExceptionRaise0(@"GSWHyperlink",@"Invoked element return a not GSWComponent element"); - }; + } else { + // call awakeInContext when _element is sleeping deeply + [_element ensureAwakeInContext:context_]; +/* + if (![_element context]) { + NSDebugMLLog(@"gswdync",@"_element sleeps, awake it = %@",_element); + [_element awakeInContext:context_]; + } +*/ + } }; } else if (pageName) diff --git a/GSWeb.framework/GSWImageButton.m b/GSWeb.framework/GSWImageButton.m index 0ac1ce3..7813a89 100644 --- a/GSWeb.framework/GSWImageButton.m +++ b/GSWeb.framework/GSWImageButton.m @@ -403,6 +403,22 @@ static char rcsId[] = "$Id$"; { [context_ _setActionInvoked:YES]; _element=[_actionAssociation valueInComponent:_component]; + if (_element) + { + if (![_element isKindOfClass:[GSWComponent class]]) //TODO GSWComponent or Element ? + { + ExceptionRaise0(@"GSWHyperlink",@"Invoked element return a not GSWComponent element"); + } else { + // call awakeInContext when _element is sleeping deeply + [_element ensureAwakeInContext:context_]; +/* + if (![_element context]) { + NSDebugMLLog(@"gswdync",@"_element sleeps, awake it = %@",_element); + [_element awakeInContext:context_]; + } +*/ + } + } } else { diff --git a/GSWeb.framework/GSWKeyValueAssociation.m b/GSWeb.framework/GSWKeyValueAssociation.m index 2fbbabd..0a591f7 100644 --- a/GSWeb.framework/GSWKeyValueAssociation.m +++ b/GSWeb.framework/GSWKeyValueAssociation.m @@ -65,7 +65,7 @@ static char rcsId[] = "$Id$"; NSDebugMLLog(@"associations",@"retValue=%@ (%p) (class=%@)", retValue, retValue, - [retValue class]); + NSStringFromClass([retValue class])); [self logTakeValue:retValue]; LOGObjectFnStop(); return retValue; @@ -77,7 +77,7 @@ static char rcsId[] = "$Id$"; { LOGObjectFnStart(); NSDebugMLLog(@"associations",@"GSWAssociation: setValue:%@ (self=%@)",value_,self); - NSDebugMLLog(@"associations",@"value_ class:%@",[value_ class]); + NSDebugMLLog(@"associations",@"value_ class:%@",NSStringFromClass([value_ class])); NSDebugMLLog(@"associations",@"value_ String class:%@",NSStringFromClass([value_ class])); //TODO (return something!) [object_ validateValue:&value_ diff --git a/GSWeb.framework/GSWPopUpButton.m b/GSWeb.framework/GSWPopUpButton.m index 2af7a31..03202f6 100644 --- a/GSWeb.framework/GSWPopUpButton.m +++ b/GSWeb.framework/GSWPopUpButton.m @@ -179,7 +179,8 @@ static char rcsId[] = "$Id$"; _noSelectionStringValue=[noSelectionString valueInComponent:_component]; if (_escapeHTML) _noSelectionStringValue=[GSWResponse stringByEscapingHTMLString:_noSelectionStringValue]; - [response_ appendContentHTMLString:_noSelectionStringValue]; + [response_ appendContentString:_noSelectionStringValue]; + //[response_ appendContentHTMLString:_noSelectionStringValue]; // There is no close tag on OPTION //[response_ _appendContentAsciiString:@""]; }; @@ -244,7 +245,11 @@ static char rcsId[] = "$Id$"; NSDebugMLLog(@"gswdync",@"displayString=%@",displayString); _displayStringValue=[displayString valueInComponent:_component]; NSDebugMLLog(@"gswdync",@"_displayStringValue=%@",_displayStringValue); - }; + } + else + { + _displayStringValue = _itemValue; + } if (_displayStringValue) { @@ -283,7 +288,8 @@ static char rcsId[] = "$Id$"; _displayStringValue=[NSString stringWithFormat:@"%@ --",_displayStringValue]; }; #endif - [response_ appendContentHTMLString:_displayStringValue]; + [response_ appendContentString:_displayStringValue]; + //[response_ appendContentHTMLString:_displayStringValue]; }; if (_valueValue) { diff --git a/GSWeb.framework/GSWRequest.h b/GSWeb.framework/GSWRequest.h index 9926705..37ff8cd 100644 --- a/GSWeb.framework/GSWRequest.h +++ b/GSWeb.framework/GSWRequest.h @@ -61,6 +61,7 @@ -(id)copyWithZone:(NSZone*)zone_; -(NSData*)content; +-(NSDictionary*)headers; -(NSString*)headerForKey:(NSString*)key_; -(NSArray*)headerKeys; -(NSArray*)headersForKey:(NSString*)key_; diff --git a/GSWeb.framework/GSWRequest.m b/GSWeb.framework/GSWRequest.m index 96d3d49..08a9eca 100644 --- a/GSWeb.framework/GSWRequest.m +++ b/GSWeb.framework/GSWRequest.m @@ -171,6 +171,14 @@ static char rcsId[] = "$Id$"; return [headers objectForKey:key_]; }; +//-------------------------------------------------------------------- +// headers + +-(NSDictionary*)headers +{ + return headers; +} + //-------------------------------------------------------------------- // httpVersion @@ -853,12 +861,15 @@ method=%@, uri=%@, httpVersion=%@, headers=%@, content=%@, userInfo=%@, defaultF //We can get something like // multipart/form-data; boundary=---------------------------1810101926251 // In this case, return only multipart/form-data - _range=[_contentType rangeOfString:@";"]; - if (_range.length>0) - { - _contentType=[_contentType substringToIndex:_range.location]; - NSDebugMLLog(@"requests",@"_contentType=%@",_contentType); - }; + if (_contentType) + { + _range=[_contentType rangeOfString:@";"]; + if (_range.length>0) + { + _contentType=[_contentType substringToIndex:_range.location]; + NSDebugMLLog(@"requests",@"_contentType=%@",_contentType); + }; + }; LOGObjectFnStop(); return _contentType; }; @@ -1761,7 +1772,7 @@ into NSString* _requestHandlerKey=nil; int _applicationNumber; LOGObjectFnStart(); - _dict=[NSMutableDictionary new]; + _dict=[[NSMutableDictionary new] autorelease]; //NEW//TODO _requestHandlerKey=[((GSWDynamicURLString*)[self uri]) urlRequestHandlerKey]; if (!_requestHandlerKey diff --git a/GSWeb.framework/GSWResponse.h b/GSWeb.framework/GSWResponse.h index 0ca5c64..fd653d8 100644 --- a/GSWeb.framework/GSWResponse.h +++ b/GSWeb.framework/GSWResponse.h @@ -62,6 +62,8 @@ forKey:(NSString*)key_; -(void)setHeaders:(NSArray*)headerList_ forKey:(NSString*)key_; +-(void)setHeaders:(NSDictionary*)headerList_; +-(NSMutableDictionary*)headers; -(void)setHTTPVersion:(NSString*)version_; -(void)setStatus:(unsigned int)status_; -(void)setUserInfo:(NSDictionary*)userInfo_; @@ -159,4 +161,16 @@ inContext:(GSWContext*)context_ forRequest:(GSWRequest*)request_; @end + +//==================================================================== +@interface GSWResponse (GSWResponseRefused) + +//-------------------------------------------------------------------- +// +//Refuse Response ++(GSWResponse*)generateRefusingResponseInContext:(GSWContext*)context_ + forRequest:(GSWRequest*)request_; +@end + + #endif //_GSWResponse_h__ diff --git a/GSWeb.framework/GSWResponse.m b/GSWeb.framework/GSWResponse.m index 7d7e70f..2eb355b 100644 --- a/GSWeb.framework/GSWResponse.m +++ b/GSWeb.framework/GSWResponse.m @@ -201,6 +201,36 @@ NSStringEncoding globalDefaultEncoding=NSISOLatin1StringEncoding; forKey:key_]; }; +//-------------------------------------------------------------------- +// setHeaders: + +-(void)setHeaders:(NSDictionary*)headerDictionary +{ + if (!headers) + headers=[NSMutableDictionary new]; + + if (headerDictionary) + { + NSEnumerator *keyEnum; + id headerName; + + keyEnum = [headerDictionary keyEnumerator]; + while (headerName = [keyEnum nextObject]) + { + [self setHeaders:[NSArray arrayWithObject:[headerDictionary objectForKey:headerName]] + forKey:headerName]; + } + } +} + +//-------------------------------------------------------------------- +// headers + +-(NSMutableDictionary*)headers +{ + return headers; +} + //-------------------------------------------------------------------- // setHTTPVersion: @@ -643,8 +673,9 @@ NSStringEncoding globalDefaultEncoding=NSISOLatin1StringEncoding; //-------------------------------------------------------------------- -(GSWResponse*)generateResponse { - LOGObjectFnNotImplemented(); //TODOFN - return nil; + //LOGObjectFnNotImplemented(); //TODOFN + //return nil; + return self; }; @end @@ -701,3 +732,62 @@ NSStringEncoding globalDefaultEncoding=NSISOLatin1StringEncoding; @end +//==================================================================== +@implementation GSWResponse (GSWResponseRefused) + +//-------------------------------------------------------------------- +// +//Refuse Response ++(GSWResponse*)generateRefusingResponseInContext:(GSWContext*)context_ + forRequest:(GSWRequest*)request_ +{ + GSWResponse* _response=nil; + NSString* _httpVersion=nil; + LOGClassFnStart(); + _response=[[self new]autorelease]; + if (_response) + { + NSString* _responseString=nil; + NSString* _locationURLString=nil; + NSString* _message=nil; + + if (context_ && [context_ request]) + { + request_=[context_ request]; + } + _httpVersion=[request_ httpVersion]; + if (_httpVersion) + { + [_response setHTTPVersion:_httpVersion]; + } + + [_response setStatus:302]; + _locationURLString = [NSString stringWithFormat:@"%@/%@.gswa",[request_ adaptorPrefix], [request_ applicationName]]; + if (_locationURLString) + { + [_response setHeader: _locationURLString forKey:@"location"]; + } + [_response setHeader:@"text/html" forKey:@"content-type"]; + [_response setHeader:@"YES" forKey:@"x-gsweb-refusing-redirection"]; + + if (context_) + { + [context_ _setResponse:_response]; + } + + _message = [NSString stringWithFormat:@"Sorry, your request could not immediately be processed. Please try this URL: %@\nConnection closed by foreign host.", + _locationURLString, _locationURLString]; + + _responseString=[NSString stringWithFormat:@"\nGNUstepWeb\n\n\n
\n%@\n
\n\n\n", + _message]; + //[[_response class]stringByEscapingHTMLString:_message]]; + [_response appendContentString:_responseString]; + + [_response setHeader:[NSString stringWithFormat:@"%d", [[_response content] length]] forKey:@"content-length"]; + }; + LOGClassFnStop(); + return _response; +}; + +@end + diff --git a/GSWeb.framework/GSWServerSessionStore.h b/GSWeb.framework/GSWServerSessionStore.h index c813144..b933045 100644 --- a/GSWeb.framework/GSWServerSessionStore.h +++ b/GSWeb.framework/GSWServerSessionStore.h @@ -44,4 +44,10 @@ @end +//==================================================================== +@interface GSWServerSessionStore (GSWServerSessionStoreInfo) +-(BOOL)containsSessionID:(NSString*)sessionID_; +-(NSArray *)allSessionIDs; +@end + #endif //_GSWServerSessionStore_h__ diff --git a/GSWeb.framework/GSWServerSessionStore.m b/GSWeb.framework/GSWServerSessionStore.m index a15a3c8..a292de5 100644 --- a/GSWeb.framework/GSWServerSessionStore.m +++ b/GSWeb.framework/GSWServerSessionStore.m @@ -37,6 +37,7 @@ static char rcsId[] = "$Id$"; sessions=[NSMutableDictionary new]; [timeOut_manager setCallBack:@selector(removeSessionWithID:) target:self]; + [timeOut_manager startHandleTimerRefusingSessions]; }; LOGObjectFnStop(); return self; @@ -128,3 +129,25 @@ static char rcsId[] = "$Id$"; @end +//==================================================================== +@implementation GSWServerSessionStore (GSWServerSessionStoreInfo) +-(BOOL)containsSessionID:(NSString*)sessionID_ +{ + BOOL contain = NO; + //OK + LOGObjectFnStart(); + if([sessions objectForKey:sessionID_]) + { + contain = YES; + } + LOGObjectFnStop(); + return contain; +}; + +-(NSArray *)allSessionIDs +{ + return [sessions allKeys]; +} + +@end + diff --git a/GSWeb.framework/GSWSession.m b/GSWeb.framework/GSWSession.m index 68a8612..8bbc769 100644 --- a/GSWeb.framework/GSWSession.m +++ b/GSWeb.framework/GSWSession.m @@ -315,6 +315,7 @@ static char rcsId[] = "$Id$"; isTerminating=YES; _sessionID=[self sessionID]; + [self setTimeOut:(NSTimeInterval) 1]; // forces to call removeSessionWithID in GSWServerSessionStore to dealloc it [[NSNotificationCenter defaultCenter] postNotificationName:GSWNotification__SessionDidTimeOutNotification[GSWebNamingConv] object:_sessionID]; //goto => GSWApp _sessionDidTimeOutNotification: diff --git a/GSWeb.framework/GSWSessionStore.h b/GSWeb.framework/GSWSessionStore.h index 291c51e..58defd0 100644 --- a/GSWeb.framework/GSWSessionStore.h +++ b/GSWeb.framework/GSWSessionStore.h @@ -86,5 +86,4 @@ -(void)_validateAPI; @end - #endif //_GSWSessionStore_h__ diff --git a/GSWeb.framework/GSWSessionStore.m b/GSWeb.framework/GSWSessionStore.m index 54f2855..04715ae 100644 --- a/GSWeb.framework/GSWSessionStore.m +++ b/GSWeb.framework/GSWSessionStore.m @@ -388,9 +388,3 @@ static char rcsId[] = "$Id$"; - - - - - - diff --git a/GSWeb.framework/GSWSessionTimeOutManager.h b/GSWeb.framework/GSWSessionTimeOutManager.h index 1b2c4e0..a879809 100644 --- a/GSWeb.framework/GSWSessionTimeOutManager.h +++ b/GSWeb.framework/GSWSessionTimeOutManager.h @@ -30,7 +30,8 @@ //==================================================================== @interface GSWSessionTimeOutManager : NSObject { - NSMutableOrderedArray* sessionOrderedTimeOuts; + //NSMutableOrderedArray* sessionOrderedTimeOuts; + NSMutableArray* sessionOrderedTimeOuts; NSMutableDictionary* sessionTimeOuts; id target; SEL callback; @@ -56,4 +57,12 @@ -(void)unlock; @end +//==================================================================== +@interface GSWSessionTimeOutManager (GSWSessionRefused) + +-(void)startHandleTimerRefusingSessions; +-(void)handleTimerKillingApplication:(id)timer_; +-(void)handleTimerRefusingSessions:(id)timer_; + +@end #endif //_GSWSessionTimeOutManager_h__ diff --git a/GSWeb.framework/GSWSessionTimeOutManager.m b/GSWeb.framework/GSWSessionTimeOutManager.m index e25517b..0107091 100644 --- a/GSWeb.framework/GSWSessionTimeOutManager.m +++ b/GSWeb.framework/GSWSessionTimeOutManager.m @@ -33,7 +33,8 @@ static char rcsId[] = "$Id$"; //OK if ((self=[super init])) { - sessionOrderedTimeOuts=[[NSMutableOrderedArray alloc]initWithCompareSelector:@selector(compareTimeOutDate:)]; + //sessionOrderedTimeOuts=[[NSMutableOrderedArray alloc]initWithCompareSelector:@selector(compareTimeOutDate:)]; + sessionOrderedTimeOuts=[NSMutableArray new]; sessionTimeOuts=[NSMutableDictionary new]; // selfLock=[NSRecursiveLock new]; selfLock=[NSLock new]; @@ -100,6 +101,7 @@ static char rcsId[] = "$Id$"; } NS_HANDLER { + NSLog(@"### exception from ... addTimer... %@", [localException reason]); LOGException(@"%@ (%@)",localException,[localException reason]); //TODO [target unlock]; @@ -114,6 +116,7 @@ static char rcsId[] = "$Id$"; } NS_HANDLER { + NSLog(@"### exception ... %@", [localException reason]); LOGException(@"%@ (%@)",localException,[localException reason]); //TODO [self unlock]; @@ -136,14 +139,24 @@ static char rcsId[] = "$Id$"; [self lock]; NS_DURING { + NSEnumerator *_sessionTimeOutEnum = nil; GSWSessionTimeOut* _sessionTimeOut=nil; NSTimeInterval _now=[NSDate timeIntervalSinceReferenceDate]; NSTimer* _timer=nil; int _removedNb=0; + +/* if ([sessionOrderedTimeOuts count]>0) _sessionTimeOut=[sessionOrderedTimeOuts objectAtIndex:0]; - while (/*_removedNb<20 && */_sessionTimeOut && [_sessionTimeOut timeOutTime]<_now) +*/ + + _sessionTimeOutEnum = [sessionOrderedTimeOuts objectEnumerator]; + + while (/*_removedNb<20 && *//*_sessionTimeOut && [_sessionTimeOut timeOutTime]<_now*/ + _sessionTimeOut = [_sessionTimeOutEnum nextObject]) { + if ([_sessionTimeOut timeOutTime]<_now) + { id _session=nil; [target lock]; NS_DURING @@ -174,16 +187,25 @@ static char rcsId[] = "$Id$"; NSDebugMLLog(@"sessions",@"sessionOrderedTimeOuts=%@",sessionOrderedTimeOuts); [_session terminate]; NSDebugMLLog(@"sessions",@"sessionOrderedTimeOuts=%@",sessionOrderedTimeOuts); - [sessionOrderedTimeOuts removeObjectAtIndex:0]; + + NSLog(@"GSWSessionTimeOutMananger : removeObject = %@", _sessionTimeOut); + + /* [sessionOrderedTimeOuts removeObjectAtIndex:0]; */ + [sessionOrderedTimeOuts removeObject:_sessionTimeOut]; + [sessionTimeOuts removeObjectForKey:[_session sessionID]]; + NSDebugMLLog(@"sessions",@"sessionOrderedTimeOuts=%@",sessionOrderedTimeOuts); _removedNb++; + /* if ([sessionOrderedTimeOuts count]>0) _sessionTimeOut=[sessionOrderedTimeOuts objectAtIndex:0]; else _sessionTimeOut=nil; + */ } else _sessionTimeOut=nil; + }; }; _timer=[self resetTimer]; @@ -230,20 +252,46 @@ static char rcsId[] = "$Id$"; NSDebugMLLog(@"sessions",@"sessionOrderedTimeOuts=%@",sessionOrderedTimeOuts); if ([sessionOrderedTimeOuts count]>0) { - _sessionTimeOut=[sessionOrderedTimeOuts objectAtIndex:0]; + NSEnumerator * sessionOrderedTimeOutsEnum = [sessionOrderedTimeOuts objectEnumerator]; + GSWSessionTimeOut* sessionTimeOutObject=nil; + NSTimeInterval _minTimeOut; + + _sessionTimeOut = [sessionOrderedTimeOuts objectAtIndex:0]; + _minTimeOut = [_sessionTimeOut timeOutTime]; + while (sessionTimeOutObject = [sessionOrderedTimeOutsEnum nextObject]) { + if ([sessionTimeOutObject timeOutTime] < _minTimeOut) { + _sessionTimeOut = sessionTimeOutObject; + _minTimeOut = [_sessionTimeOut timeOutTime]; + } + } + + //_sessionTimeOut=[sessionOrderedTimeOuts objectAtIndex:0]; + + // search for minimum timeouts + NSDebugMLLog(@"sessions",@"_sessionTimeOut=%@",_sessionTimeOut); NSDebugMLLog(@"sessions",@"[timer fireDate]=%@",[timer fireDate]); NSDebugMLLog(@"sessions",@"[old timer isValide]=%s", [timer isValid] ? "YES" : "NO"); +/* + NSLog(@"_sessionTimeOut=%@",_sessionTimeOut); + NSLog(@"[old timer isValide]=%s", [timer isValid] ? "YES" : "NO"); + NSLog(@"[_sessionTimeOut timeOutTime] = %ld",(long)[_sessionTimeOut timeOutTime]); + NSLog(@"_timerFireTimeInterval = %ld",(long) _timerFireTimeInterval); + NSLog(@"_now = %ld",(long) _now); +*/ if (_sessionTimeOut && (![timer isValid] || [_sessionTimeOut timeOutTime]<_timerFireTimeInterval || _timerFireTimeInterval<_now)) { NSTimeInterval _timerTimeInterval=[_sessionTimeOut timeOutTime]-_now; + + NSDebugMLLog(@"sessions",@"_timerTimeInterval=%ld",(long)_timerTimeInterval); + _timerTimeInterval=max(_timerTimeInterval,1);//20s minimum NSDebugMLLog(@"sessions",@"_timerTimeInterval=%ld",(long)_timerTimeInterval); - _timerTimeInterval=max(_timerTimeInterval,10);//20s minimum - NSDebugMLLog(@"sessions",@"_timerTimeInterval=%ld",(long)_timerTimeInterval); + NSLog(@"new _timerTimeInterval=%ld",(long)_timerTimeInterval); + _newTimer=[NSTimer timerWithTimeInterval:_timerTimeInterval target:self selector:@selector(handleTimer:) @@ -330,4 +378,168 @@ static char rcsId[] = "$Id$"; LOGObjectFnStop(); }; +@end + +//==================================================================== +@implementation GSWSessionTimeOutManager (GSWSessionRefused) + +//-------------------------------------------------------------------- +-(void)startHandleTimerRefusingSessions +{ + NSTimer* _newTimer = nil; + +NSLog(@"---Start startHandleTimerRefusingSessions"); + //[GSWApplication statusLogWithFormat:@"Start startHandleTimerRefusingSessions"]; + //LOGObjectFnStart(); + [self lock]; +/* + _newTimer=[NSTimer timerWithTimeInterval:5 // first time after 5 seconds + target:self + selector:@selector(handleTimerRefusingSessions:) + userInfo:nil + repeats:NO]; + + if (_newTimer) { + [GSWApp addTimer:_newTimer]; + } +*/ + + _newTimer = [NSTimer scheduledTimerWithTimeInterval:5 + target:self + selector:@selector(handleTimerRefusingSessions:) + userInfo:nil + repeats:NO]; + + [self unlock]; + //LOGObjectFnStop(); + //[GSWApplication statusLogWithFormat:@"Stop startHandleTimerRefusingSessions"]; +NSLog(@"---Stop startHandleTimerRefusingSessions"); +} + +//-------------------------------------------------------------------- +-(void)handleTimerKillingApplication:(id)timer_ +{ + NSLog(@"application is shutting down..."); + [GSWApp lock]; + [GSWApp lockRequestHandling]; + [self lock]; + [GSWApp dealloc]; + [GSWApplication dealloc]; // call class method , not instance method + exit(0); +} + +//-------------------------------------------------------------------- +-(void)handleTimerRefusingSessions:(id)timer_ +{ + //OK +//NSLog(@"-Start HandleTimerRefusingSessions"); + //[GSWApplication statusLogWithFormat:@"-Start HandleTimerRefusingSessions"]; + //[GSWApp lockRequestHandling]; + NS_DURING + { + [self lock]; + NS_DURING + { + GSWApplication *ourApp = [GSWApplication application]; + NSTimer *_timer=nil; + + if (ourApp && [ourApp isRefusingNewSessions] && ([sessionOrderedTimeOuts count] <= [ourApp minimumActiveSessionsCount])) { + + // okay , soft-shutdown for all avtive sessions + + GSWSessionTimeOut *_sessionTimeOut=nil; + + while ([sessionOrderedTimeOuts count] > 0) { + + _sessionTimeOut = [sessionOrderedTimeOuts lastObject]; + if (_sessionTimeOut) { + + id _session=nil; + [target lock]; + NS_DURING + { + _session=[target performSelector:callback + withObject:[_sessionTimeOut sessionID]]; + NSDebugMLLog(@"sessions",@"_session=%@",_session); + } + NS_HANDLER + { + LOGException(@"%@ (%@)",localException,[localException reason]); + //TODO + [target unlock]; + _timer = [NSTimer scheduledTimerWithTimeInterval:5 + target:self + selector:@selector(handleTimerRefusingSessions:) + userInfo:nil + repeats:NO]; + + [self unlock]; + //[GSWApp unlockRequestHandling]; + [localException raise]; + } + NS_ENDHANDLER; + [target unlock]; + + if (_session) + { + NSDebugMLLog(@"sessions",@"sessionOrderedTimeOuts=%@",sessionOrderedTimeOuts); + [_session terminate]; // ??? + NSDebugMLLog(@"sessions",@"sessionOrderedTimeOuts=%@",sessionOrderedTimeOuts); + + NSLog(@"GSWSessionTimeOutMananger : removeObject = %@", _sessionTimeOut); + + [sessionOrderedTimeOuts removeObject:_sessionTimeOut]; + [sessionTimeOuts removeObjectForKey:[_session sessionID]]; + + NSDebugMLLog(@"sessions",@"sessionOrderedTimeOuts=%@",sessionOrderedTimeOuts); + } + + } + } + // app terminate + NSLog(@"application is preparing to shut down in 10 sec..."); + + _timer = [NSTimer scheduledTimerWithTimeInterval:10 + target:self + selector:@selector(handleTimerKillingApplication:) + userInfo:nil + repeats:NO]; + + } else + { + // new timer, app does not terminate + _timer = [NSTimer scheduledTimerWithTimeInterval:5 + target:self + selector:@selector(handleTimerRefusingSessions:) + userInfo:nil + repeats:NO]; + + } + } + NS_HANDLER + { + LOGException(@"%@ (%@)",localException,[localException reason]); + //TODO + [self unlock]; + //[GSWApp unlockRequestHandling]; + [localException raise]; + }; + NS_ENDHANDLER; + NSDebugMLLog(@"sessions",@"sessionOrderedTimeOuts=%@",sessionOrderedTimeOuts); + [self unlock]; + } + NS_HANDLER + { + LOGException(@"%@ (%@)",localException,[localException reason]); + //TODO + //[GSWApp unlockRequestHandling]; + [localException raise]; + }; + NS_ENDHANDLER; + //[GSWApp unlockRequestHandling]; + //[GSWApplication statusLogWithFormat:@"-Stop HandleTimerRefusingSessions"]; +//NSLog(@"-Stop HandleTimerRefusingSessions"); +}; + + @end diff --git a/GSWeb.framework/GSWSubmitButton.m b/GSWeb.framework/GSWSubmitButton.m index 81d174b..805e3cf 100644 --- a/GSWeb.framework/GSWSubmitButton.m +++ b/GSWeb.framework/GSWSubmitButton.m @@ -148,8 +148,30 @@ static char rcsId[] = "$Id$"; NS_ENDHANDLER; if (_actionValue) _element=_actionValue; + if (_element) + { + if (![_element isKindOfClass:[GSWComponent class]]) //TODO GSWComponent or Element ? + { + ExceptionRaise0(@"GSWHyperlink",@"Invoked element return a not GSWComponent element"); + } + else + { + // call awakeInContext when _element is sleeping deeply + [_element ensureAwakeInContext:context_]; + /* + if (![_element context]) { + NSDebugMLLog(@"gswdync",@"_element sleeps, awake it = %@",_element); + [_element awakeInContext:context_]; + } else { + [_element awakeInContext:context_]; + } + */ + } + } + /* ??? if (!_element) _element=[context_ page]; + */ }; }; }; diff --git a/GSWeb.framework/GSWTemplateParser.m b/GSWeb.framework/GSWTemplateParser.m index 9c9c03f..2312623 100644 --- a/GSWeb.framework/GSWTemplateParser.m +++ b/GSWeb.framework/GSWTemplateParser.m @@ -232,7 +232,24 @@ Class GSWTemplateParser_DefaultParserClass=Nil; NS_ENDHANDLER; if (elements) { + NSRange docTypeRangeStart=NSMakeRange(NSNotFound,0); + NSRange docTypeRangeEnd=NSMakeRange(NSNotFound,0); + _template=[[GSWHTMLStaticGroup alloc]initWithContentElements:elements]; + + //NSLog(@"_string = %@", _string); + + docTypeRangeStart=[_string rangeOfString:@""]; + if (docTypeRangeEnd.length) { + if (docTypeRangeStart.location < docTypeRangeEnd.location) + { + [_template setDocumentTypeString:[_string substringFromRange:NSMakeRange(docTypeRangeStart.location, + docTypeRangeEnd.location - docTypeRangeStart.location + 1)]]; + } + } + } }; }; }; diff --git a/GSWeb.framework/GSWTemplateParserXML.m b/GSWeb.framework/GSWTemplateParserXML.m index d57d0af..ccbd14c 100644 --- a/GSWeb.framework/GSWTemplateParserXML.m +++ b/GSWeb.framework/GSWTemplateParserXML.m @@ -130,7 +130,7 @@ extern void externalSubset (void *ctx, if ((self=[self init])) { _templateParser=templateParser_; - NSLog(@"my sax lib=%p",lib); + //NSLog(@"my sax lib=%p",lib); if (lib) { xmlSAXHandlerPtr def=NULL; @@ -504,7 +504,6 @@ static NSString* TabsForLevel(int level) else stringToParse=_string; stringToParse=[xmlHeader stringByAppendingString:stringToParse]; - NSLog(@"stringToParse=%@",stringToParse); parser=[GSXMLParser parserWithSAXHandler:sax withData:[stringToParse dataUsingEncoding:stringEncoding]]; }; @@ -556,6 +555,19 @@ static NSString* TabsForLevel(int level) NSDebugMLLog0(@"low",@"_xmlDocument dumped"); }; #endif +/* + if ([node type]==XML_DTD_NODE) { + NSLog(@"GSWTemplateParserXML: XML_DTD_NODE is found"); + } + + NSLog(@"ROOT node=%p %@ [Type:%@] [%@] ##%s##\n", + node, + [node name], + [node typeDescription], + [node propertiesAsDictionary], + [[node content] lossyCString]); +*/ + /* if (node->type!=XML_DTD_NODE) { NSLog(@"Bad first node type: %@ instead of %@", @@ -589,6 +601,14 @@ static NSString* TabsForLevel(int level) (_isHTMLTag ? "YES" : "NO"), (_isBodyTag ? "YES" : "NO")); */ +/* + NSLog(@"while1 node=%p %@ [Type:%@] [%@] ##%s##\n", + node, + [node name], + [node typeDescription], + [node propertiesAsDictionary], + [[node content] lossyCString]); +*/ if ((!_isHTMLTag && [nodeName caseInsensitiveCompare:@"html"]==NSOrderedSame) || (!_isBodyTag && [nodeName caseInsensitiveCompare:@"body"]==NSOrderedSame)) { @@ -665,17 +685,27 @@ text [Type:XML_TEXT_NODE] [{}] #### [currentNode name], [currentNode typeDescription], [currentNode propertiesAsDictionary], +/* ((xmlNodePtr)[currentNode lib])->content, + [currentNode content],*/ [[currentNode content] lossyCString]); + switch([currentNode type]) { case XML_TEXT_NODE: { NSDebugMLog0(@"TEXT"); - elem=[GSWHTMLBareString elementWithString: - [NSString stringWithCString: - [[[currentNode content] - stringByConvertingToHTMLEntities] - lossyCString]]];//Because XML Parser decode characters + + if ([currentNode content] && ([[currentNode content] length] > 0) ) { + + elem=[GSWHTMLBareString elementWithString: + [NSString stringWithCString: + [[[currentNode content] + stringByConvertingToHTMLEntities] + lossyCString]]];//Because XML Parser decode characters + } else { + elem = nil; + } + NSDebugMLog(@"TEXT element=%@",elem); }; break; @@ -878,7 +908,8 @@ text [Type:XML_TEXT_NODE] [{}] #### }; break; }; - [_elements addObject:elem]; + if (elem) + [_elements addObject:elem]; NSDebugMLog(@"END node=%p %@ [Type:%@] [%@] ##%s##\n", currentNode, [currentNode name], diff --git a/GSWeb.framework/GSWUtils.h b/GSWeb.framework/GSWUtils.h index 8da7cd3..1c7b7de 100644 --- a/GSWeb.framework/GSWUtils.h +++ b/GSWeb.framework/GSWUtils.h @@ -24,7 +24,7 @@ #ifndef _GSWebUtils_h__ #define _GSWebUtils_h__ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__NetBSD__) #include #endif diff --git a/GSWeb.framework/GSWWOCompatibility.h b/GSWeb.framework/GSWWOCompatibility.h index bef2c14..a5b0600 100644 --- a/GSWeb.framework/GSWWOCompatibility.h +++ b/GSWeb.framework/GSWWOCompatibility.h @@ -230,18 +230,27 @@ @interface WOFrame : GSWFrame @end +@interface WOGenericContainer : GSWGenericContainer +@end + @interface WOGenericElement : GSWGenericElement @end @interface WOImage : GSWImage @end +@interface WOImageButton : GSWImageButton +@end + @interface WORadioButton : GSWRadioButton @end @interface WORadioButtonList : GSWRadioButtonList @end +@interface WOHyperlink : GSWHyperlink +@end + #endif #endif // _GSWWOCompatibility_h__ diff --git a/GSWeb.framework/GSWWOCompatibility.m b/GSWeb.framework/GSWWOCompatibility.m index 4faa09d..2cd10c1 100644 --- a/GSWeb.framework/GSWWOCompatibility.m +++ b/GSWeb.framework/GSWWOCompatibility.m @@ -229,18 +229,27 @@ static char rcsId[] = "$Id$"; @implementation WOFrame @end +@implementation WOGenericContainer +@end + @implementation WOGenericElement @end @implementation WOImage @end +@implementation WOImageButton +@end + @implementation WORadioButton @end @implementation WORadioButtonList @end +@implementation WOHyperlink +@end + #endif diff --git a/GSWeb.framework/NSObject+IVarAccess+PerformSel.m b/GSWeb.framework/NSObject+IVarAccess+PerformSel.m index aa230c5..3f2f9d7 100644 --- a/GSWeb.framework/NSObject+IVarAccess+PerformSel.m +++ b/GSWeb.framework/NSObject+IVarAccess+PerformSel.m @@ -175,37 +175,64 @@ const char* GSGetInstanceVariableType(id obj, #if GDL2 //-------------------------------------------------------------------- + - (id)getIVarNamed:(NSString *)name_ { id value; + SEL sel = NSSelectorFromString(@"valueForKey:"); + id (*imp)(id, SEL, id) = (id (*)(id, SEL, id))[NSObject instanceMethodForSelector: sel]; + + //NSLog(@"%@",name_); + //NSLog(@"sel (valueForKey ) : %d", (int)sel); - NSLog(@"%@", name_); NS_DURING - value = [self valueForKey:name_]; + //value = [self valueForKey:name_]; + value = (*imp)(self, sel, name_); NS_HANDLER { - if([self respondsToSelector:@selector(objectForKey:)] == YES) - value = [self objectForKey:name_]; - else - [localException raise]; + if([self respondsToSelector:@selector(objectForKey:)] == YES) { + if (name_) { + value = [self objectForKey:name_]; + } else { + value=nil; + } + } else { + [localException raise]; + } } NS_ENDHANDLER; return value; } + //-------------------------------------------------------------------- - (void)setIVarNamed:(NSString *)name_ withValue:(id)value_ { + SEL sel = NSSelectorFromString(@"takeValue:forKey:"); + id (*imp)(id, SEL, id, id) = (id (*)(id, SEL, id, id))[NSObject instanceMethodForSelector: sel]; + + //NSLog(@"sel (takeValue:forKey: ) : %d", (int)sel); + NS_DURING - [self takeValue:value_ forKey:name_]; +//NSLog(@"setIVarNamed : self = %@", NSStringFromClass([self class])); +//NSLog(@"setIVarNamed : name_ = %@ (%@)", name_, NSStringFromClass([name_ class])); +//NSLog(@"setIVarNamed : value_ = %@ (%@)", value_, NSStringFromClass([value_ class])); + //[self takeValue:value_ forKey:name_]; + (*imp)(self, sel, value_, name_); NS_HANDLER { - if([self respondsToSelector:@selector(setObject:forKey:)] == YES) - [self setObject:value_ forKey:name_]; - else - [localException raise]; + if (![name_ isEqualToString:@"self"]) { + + if([self respondsToSelector:@selector(setObject:forKey:)] == YES) { + if (value_ && name_) { + [self setObject:value_ forKey:name_]; + } + } else { + [localException raise]; + } + } } NS_ENDHANDLER; } @@ -412,7 +439,7 @@ void IdToPData(const char* retType,id _value,void* pdata) Class _class=Nil; NSObjectIVarsAccess* _ivarAccess=nil; NSMutableDictionary* _classCache=nil; -// LOGObjectFnStart(); + //LOGObjectFnStart(); NSDebugMLLog(@"low",@"getIVarNamed %@ in %p %@ (superClass:%@)",name_,self,[self class],[self superclass]); _class=[self class]; _classCache=[objectIVarAccessCache_Get objectForKey:_class]; diff --git a/GSWeb.framework/attach.m b/GSWeb.framework/attach.m index 7cd40d0..5f095d8 100644 --- a/GSWeb.framework/attach.m +++ b/GSWeb.framework/attach.m @@ -15,7 +15,7 @@ * ************************************************************************/ -#if defined(unix) || defined(__unix) || defined(__xlC__) +#if defined(unix) || defined(__unix) || defined(__xlC__) || defined(__NetBSD__) # define PLATFORM_UNIX #elif defined(WIN32) || defined(_WIN32) # define PLATFORM_WIN32 diff --git a/GSWeb.framework/stacktrace.m b/GSWeb.framework/stacktrace.m index 8560805..02dfbb4 100644 --- a/GSWeb.framework/stacktrace.m +++ b/GSWeb.framework/stacktrace.m @@ -32,7 +32,7 @@ ************************************************************************/ #define USE_BUILTIN -#if defined(unix) || defined(__unix) || defined(__xlC__) +#if defined(unix) || defined(__unix) || defined(__xlC__) || defined(__NetBSD__) # define PLATFORM_UNIX #elif defined(WIN32) || defined(_WIN32) # define PLATFORM_WIN32 diff --git a/README b/README index 2e31a61..3a87986 100644 --- a/README +++ b/README @@ -50,5 +50,8 @@ Special Thanks * Catherine Biscourp for the GNUstepWeb logos and some other things... +* David Wetzel from Turbocat and Kim Shrier + for patches + -------------------------------------------------------------------------------- Note: All trademarks mentioned on this server belong to their respective owners. \ No newline at end of file