2000-01-22 12:49:49 +00:00
|
|
|
/* GSWHTTPResponse.c - GSWeb: Adaptors: HTTP Response
|
2003-02-28 18:37:43 +00:00
|
|
|
Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
2003-02-28 18:37:43 +00:00
|
|
|
Date: July 1999
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
This file is part of the GNUstep Web Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
|
|
|
License along with this library; if not, write to the Free
|
|
|
|
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "GSWUtil.h"
|
|
|
|
#include "GSWDict.h"
|
|
|
|
#include "GSWString.h"
|
|
|
|
#include "GSWURLUtil.h"
|
|
|
|
#include "GSWConfig.h"
|
|
|
|
#include "GSWHTTPHeaders.h"
|
|
|
|
#include "GSWAppRequestStruct.h"
|
|
|
|
#include "GSWAppConnect.h"
|
|
|
|
#include "GSWHTTPRequest.h"
|
|
|
|
#include "GSWHTTPResponse.h"
|
|
|
|
#include "GSWAppRequest.h"
|
2000-03-16 16:16:49 +00:00
|
|
|
#include "GSWTemplates.h"
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
|
2003-02-28 18:37:43 +00:00
|
|
|
static char *g_pszLocalHostName = NULL;
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
#define STATUS "Status"
|
|
|
|
#define HTTP_SLASH "HTTP/"
|
|
|
|
|
2000-03-16 16:16:49 +00:00
|
|
|
//--------------------------------------------------------------------
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWHTTPResponse *
|
|
|
|
GSWHTTPResponse_New(CONST char *p_pszStatus,
|
|
|
|
void *p_pLogServerData)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWHTTPResponse *pHTTPResponse=NULL;
|
2000-01-22 12:49:49 +00:00
|
|
|
BOOL fOk=FALSE;
|
|
|
|
// Accept "HTTP/1.0 200 OK GSWeb..." and "HTTP/1.0 200 OK GNUstep GSWeb..."
|
2001-12-11 14:35:30 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
GSWLog(GSW_INFO,p_pLogServerData,"p_pszStatus=%s",p_pszStatus);
|
|
|
|
#endif
|
2000-01-22 12:49:49 +00:00
|
|
|
if (strncmp(p_pszStatus,HTTP_SLASH,strlen(HTTP_SLASH))==0)
|
2003-02-28 18:37:43 +00:00
|
|
|
{
|
|
|
|
// Status Code
|
|
|
|
CONST char *pszSpace=strchr(p_pszStatus,' ');
|
|
|
|
if (pszSpace)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
unsigned int uStatus=0;
|
|
|
|
fOk=TRUE;
|
|
|
|
pszSpace++;
|
|
|
|
uStatus=atoi(pszSpace);
|
2001-12-11 14:35:30 +00:00
|
|
|
#ifdef DEBUG
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWLog(GSW_INFO,p_pLogServerData,"uStatus=%u",uStatus);
|
2001-12-11 14:35:30 +00:00
|
|
|
#endif
|
2003-02-28 18:37:43 +00:00
|
|
|
for(;fOk && *pszSpace && !isspace(*pszSpace);pszSpace++)
|
|
|
|
fOk=isdigit(*pszSpace);
|
2001-12-11 14:35:30 +00:00
|
|
|
#ifdef DEBUG
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWLog(GSW_INFO,p_pLogServerData,"fOk=%d",(int)fOk);
|
2001-12-11 14:35:30 +00:00
|
|
|
#endif
|
2003-02-28 18:37:43 +00:00
|
|
|
if (fOk)
|
|
|
|
{
|
|
|
|
pHTTPResponse = calloc(1,sizeof(GSWHTTPResponse));
|
|
|
|
memset(pHTTPResponse,0,sizeof(GSWHTTPResponse));
|
|
|
|
pHTTPResponse->uStatus=uStatus;
|
|
|
|
pHTTPResponse->pHeaders = GSWDict_New(16);
|
|
|
|
if (*pszSpace)
|
|
|
|
{
|
|
|
|
pszSpace=strchr(pszSpace,' ');
|
|
|
|
if (pszSpace)
|
2003-03-21 14:32:57 +00:00
|
|
|
pHTTPResponse->pszStatusMessage=strdup(pszSpace+1);
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
2003-02-28 18:37:43 +00:00
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
2003-02-28 18:37:43 +00:00
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
if (!fOk)
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWLog(GSW_ERROR,p_pLogServerData,"Invalid response");
|
2000-01-22 12:49:49 +00:00
|
|
|
return pHTTPResponse;
|
|
|
|
};
|
|
|
|
|
2000-03-16 16:16:49 +00:00
|
|
|
//--------------------------------------------------------------------
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWHTTPResponse *
|
|
|
|
GSWHTTPResponse_BuildErrorResponse(GSWAppRequest *p_pAppRequest,
|
|
|
|
CONST char *p_pszMessage,
|
|
|
|
void *p_pLogServerData)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
char szBuffer[128]="";
|
|
|
|
GSWApp *pApp=NULL;
|
|
|
|
GSWString *pBuffer=GSWString_New();
|
|
|
|
GSWString *pBufferMessage=GSWString_New();
|
|
|
|
GSWHTTPResponse *pHTTPResponse=calloc(1,sizeof(GSWHTTPResponse));
|
|
|
|
char *pszString=NULL;
|
|
|
|
|
|
|
|
GSWLog(GSW_DEBUG,p_pLogServerData,
|
|
|
|
"Start GSWHTTPResponse_BuildErrorResponse");
|
2000-03-16 16:16:49 +00:00
|
|
|
if (p_pAppRequest && p_pAppRequest->pAppInstance)
|
2003-02-28 18:37:43 +00:00
|
|
|
pApp=p_pAppRequest->pAppInstance->pApp;
|
2000-03-16 16:16:49 +00:00
|
|
|
#ifdef DEBUG
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWLog(GSW_INFO,p_pLogServerData,
|
|
|
|
"Build Error Response [%s] pApp=%p",p_pszMessage,pApp);
|
2000-03-16 16:16:49 +00:00
|
|
|
#endif
|
2000-01-22 12:49:49 +00:00
|
|
|
pHTTPResponse->uStatus = 200;
|
2001-03-11 Manuel Guesdon <mguesdon@orange-concept.com>
* GSWeb.framework/GSWWOCompatibility.h/.m: added
* GSWeb.framework/GNUmakefile: added GSWWOCompatibility.h/.m
* GSWeb.framework/GSWApplication.h/m: added WOApplicationMain, handle WO/GSWeb names
* GSWeb.framework/GSWContext.m: handle WO/GSWeb names, added traces
* GSWeb.framework/GSWConstants.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWDynamicURLString.m: handle WO/GSWeb names
* GSWeb.framework/GSWProjectBundle.m/.h: handle WO/GSWeb names, suppress warnings
* GSWeb.framework/GSWSession.m: handle WO/GSWeb names
* GSWeb.framework/GSWRequest.m: handle WO/GSWeb names
* GSWeb.framework/GSWTemplateParser.m: handle WO/GSWeb names,
added tag counts to help errors hunt
* GSWeb.framework/GSWBundle.m: handle WO/GSWeb names, added traces
* GSWeb.framework/GSWResourceManager.m: handle WO/GSWeb names
* GSWeb.framework/GSWURLValuedElementData.m: handle WO/GSWeb names
* GSWeb.framework/GSWComponentRequestHandler.m: handle WO/GSWeb names
* GSWeb.framework/GSWDirectAction.m: handle WO/GSWeb names
* GSWeb.framework/GSWForm.m/.h: handle WO/GSWeb names
* GSWeb.framework/GSWHyperlink.m/.h: handle WO/GSWeb names
* GSWeb.framework/GSWResourceRequestHandler.m: handle WO/GSWeb names
* GSWeb.framework/GSWDirectActionRequestHandler.m: handle WO/GSWeb names
* GSWeb.framework/GSWActiveImage.m/.h: handle WO/GSWeb names
* GSWeb.framework/GSWBindingNameAssociation.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWBrowser.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWComponent.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWHTMLURLValuedElement.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWImageButton.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWInput.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWPopUpButton.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWString.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWAssociation.m: handle WO/GSWeb names
* GSWeb.framework/GSWCheckBox.m: handle WO/GSWeb names
* GSWeb.framework/GSWCheckBoxList.m: handle WO/GSWeb names
* GSWeb.framework/GSWComponentDefinition.m: handle WO/GSWeb names
* GSWeb.framework/GSWRadioButton.m: handle WO/GSWeb names
* GSWeb.framework/GSWRadioButtonList.m: handle WO/GSWeb names
* GSWeb.framework/GSWText.m: handle WO/GSWeb names
* GSWeb.framework/GSWTextField.m: handle WO/GSWeb names
* GSWeb.framework/GSWDeployedBundle.m: warnings
* GSWeb.framework/GSWeb.h: added include GSWeb/GSWSessionTimeOut.h, GSWWOCompatibility.h
* GSWeb.framework/GSWAdaptor.m: traces
* GSWeb.framework/GSWDefaultAdaptor.m: handle WO/GSWeb names, added traces
* GSWeb.framework/GSWDefaultAdaptorThread.m/.h: handle WO/GSWeb names
* GSWeb.framework/NSNonBlockingFileHandle.m: added traces
* GSWeb.framework/GSWTemplateParserANTLR.m: handle WO/GSWeb names
* GSWeb.framework/GSWTemplateParserXML.m: handle WO/GSWeb names
added tag count to help errors hunt
remove "Tag gsweb invalid" message
handle unicode strings in node content traces
remove html and body tags if they are not present in the template
* GSWeb.framework/GSWTemplateParseXML.h: added ivar _isHTMLTag, _isBodyTag
* GSWeb.framework/GSWSessionTimeOutManager.m: dealloc sessionOrderedTimeOuts instead
of deallocating 2 times sessionTimeOuts
* GSWExtensions.framework/French.lproj/GSWSessionRestorationErrorPage.gswc/GSWSessionRestorationErrorPage.html:
tag mismatch, Encode french characters
* GSWExtensions.framework/GSWSessionRestorationErrorPage.gswc/GSWSessionRestorationErrorPage.html:
tag mismatch
* GSWHTMLBareString.m: handle unicode strings in description
* GSWExtensions.framework/French.lproj/GSWExceptionPage.gswc/GSWExceptionPage.html:
Encode french characters, Tag Mismatch
* GSWExtensions.framework/French.lproj/GSWPageRestorationErrorPage.gswc/GSWPageRestorationErrorPage.html:
Encode french characters
* GSWExtensions.framework/French.lproj/GSWSessionCreationErrorPage.gswc/GSWSessionCreationErrorPage.html:
Encode french characters
* GSWExtensions.framework/GSWExceptionPage.gswc/GSWExceptionPage.html:
Tag Mismatch
* GSWExtensions.framework/GSWExceptionPage.gswc/GSWExceptionPage.gswd:
added convertHTMLEntities for strings
* GSWeb.framework/GSWRepetition.m: added traces, fix "count" property bug, standardize ivars
* GSWeb.framework/NSObject+IVarAccess+PerformSel.m: added traces, handle underscored ivars search
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@9332 72102866-910b-0410-8b05-ffd578937521
2001-03-11 17:15:44 +00:00
|
|
|
pHTTPResponse->pszStatusMessage = strdup(g_szOKGSWeb[GSWNAMES_INDEX]);
|
2000-01-22 12:49:49 +00:00
|
|
|
pHTTPResponse->pHeaders = GSWDict_New(2);
|
|
|
|
GSWDict_Add(pHTTPResponse->pHeaders,
|
2003-02-28 18:37:43 +00:00
|
|
|
g_szHeader_ContentType,
|
|
|
|
g_szContentType_TextHtml,
|
|
|
|
FALSE);
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWString_Append(pBufferMessage,p_pszMessage);
|
|
|
|
if (p_pAppRequest)
|
2003-02-28 18:37:43 +00:00
|
|
|
{
|
|
|
|
GSWString_SearchReplace(pBufferMessage,"##APP_NAME##",
|
|
|
|
p_pAppRequest->pszName);
|
|
|
|
sprintf(szBuffer,"%d",p_pAppRequest->iInstance);
|
|
|
|
GSWString_SearchReplace(pBufferMessage,"##APP_INSTANCE##",szBuffer);
|
|
|
|
GSWString_SearchReplace(pBufferMessage,"##APP_HOST##",
|
|
|
|
p_pAppRequest->pszHost);
|
|
|
|
sprintf(szBuffer,"%d",p_pAppRequest->iPort);
|
|
|
|
GSWString_SearchReplace(pBufferMessage,"##APP_PORT##",szBuffer);
|
|
|
|
};
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWTemplate_ReplaceStd(pBufferMessage,pApp);
|
|
|
|
|
2001-10-28 10:29:17 +00:00
|
|
|
pszString=GSWTemplate_ErrorResponseText(TRUE,pApp);
|
|
|
|
GSWString_Append(pBuffer,pszString);
|
|
|
|
free(pszString);
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWString_SearchReplace(pBuffer,"##TEXT##",pBufferMessage->pszData);
|
|
|
|
GSWTemplate_ReplaceStd(pBuffer,pApp);
|
2000-04-11 17:13:15 +00:00
|
|
|
|
2000-03-16 16:16:49 +00:00
|
|
|
pHTTPResponse->uContentLength = GSWString_Len(pBuffer);
|
2000-04-11 17:13:15 +00:00
|
|
|
pHTTPResponse->pContent = pBuffer->pszData;
|
|
|
|
GSWString_Detach(pBuffer);
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWString_Free(pBuffer);
|
|
|
|
pBuffer=NULL;
|
2000-04-11 17:13:15 +00:00
|
|
|
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWString_Free(pBufferMessage);
|
|
|
|
pBufferMessage=NULL;
|
2000-01-22 12:49:49 +00:00
|
|
|
sprintf(szBuffer,"%d",pHTTPResponse->uContentLength);
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWDict_AddStringDup(pHTTPResponse->pHeaders,
|
|
|
|
g_szHeader_ContentLength,szBuffer);
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWHTTPResponse_BuildErrorResponse");
|
2000-01-22 12:49:49 +00:00
|
|
|
return pHTTPResponse;
|
|
|
|
};
|
|
|
|
|
2000-03-16 16:16:49 +00:00
|
|
|
//--------------------------------------------------------------------
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWHTTPResponse *
|
|
|
|
GSWHTTPResponse_BuildRedirectedResponse(CONST char *p_pszRedirectPath,
|
|
|
|
void *p_pLogServerData)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWHTTPResponse *pHTTPResponse=calloc(1,sizeof(GSWHTTPResponse));
|
|
|
|
GSWLog(GSW_DEBUG,p_pLogServerData,
|
|
|
|
"Start GSWHTTPResponse_BuildRedirectedResponse");
|
2000-01-22 12:49:49 +00:00
|
|
|
pHTTPResponse->uStatus = 302;
|
2001-03-11 Manuel Guesdon <mguesdon@orange-concept.com>
* GSWeb.framework/GSWWOCompatibility.h/.m: added
* GSWeb.framework/GNUmakefile: added GSWWOCompatibility.h/.m
* GSWeb.framework/GSWApplication.h/m: added WOApplicationMain, handle WO/GSWeb names
* GSWeb.framework/GSWContext.m: handle WO/GSWeb names, added traces
* GSWeb.framework/GSWConstants.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWDynamicURLString.m: handle WO/GSWeb names
* GSWeb.framework/GSWProjectBundle.m/.h: handle WO/GSWeb names, suppress warnings
* GSWeb.framework/GSWSession.m: handle WO/GSWeb names
* GSWeb.framework/GSWRequest.m: handle WO/GSWeb names
* GSWeb.framework/GSWTemplateParser.m: handle WO/GSWeb names,
added tag counts to help errors hunt
* GSWeb.framework/GSWBundle.m: handle WO/GSWeb names, added traces
* GSWeb.framework/GSWResourceManager.m: handle WO/GSWeb names
* GSWeb.framework/GSWURLValuedElementData.m: handle WO/GSWeb names
* GSWeb.framework/GSWComponentRequestHandler.m: handle WO/GSWeb names
* GSWeb.framework/GSWDirectAction.m: handle WO/GSWeb names
* GSWeb.framework/GSWForm.m/.h: handle WO/GSWeb names
* GSWeb.framework/GSWHyperlink.m/.h: handle WO/GSWeb names
* GSWeb.framework/GSWResourceRequestHandler.m: handle WO/GSWeb names
* GSWeb.framework/GSWDirectActionRequestHandler.m: handle WO/GSWeb names
* GSWeb.framework/GSWActiveImage.m/.h: handle WO/GSWeb names
* GSWeb.framework/GSWBindingNameAssociation.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWBrowser.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWComponent.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWHTMLURLValuedElement.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWImageButton.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWInput.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWPopUpButton.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWString.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWAssociation.m: handle WO/GSWeb names
* GSWeb.framework/GSWCheckBox.m: handle WO/GSWeb names
* GSWeb.framework/GSWCheckBoxList.m: handle WO/GSWeb names
* GSWeb.framework/GSWComponentDefinition.m: handle WO/GSWeb names
* GSWeb.framework/GSWRadioButton.m: handle WO/GSWeb names
* GSWeb.framework/GSWRadioButtonList.m: handle WO/GSWeb names
* GSWeb.framework/GSWText.m: handle WO/GSWeb names
* GSWeb.framework/GSWTextField.m: handle WO/GSWeb names
* GSWeb.framework/GSWDeployedBundle.m: warnings
* GSWeb.framework/GSWeb.h: added include GSWeb/GSWSessionTimeOut.h, GSWWOCompatibility.h
* GSWeb.framework/GSWAdaptor.m: traces
* GSWeb.framework/GSWDefaultAdaptor.m: handle WO/GSWeb names, added traces
* GSWeb.framework/GSWDefaultAdaptorThread.m/.h: handle WO/GSWeb names
* GSWeb.framework/NSNonBlockingFileHandle.m: added traces
* GSWeb.framework/GSWTemplateParserANTLR.m: handle WO/GSWeb names
* GSWeb.framework/GSWTemplateParserXML.m: handle WO/GSWeb names
added tag count to help errors hunt
remove "Tag gsweb invalid" message
handle unicode strings in node content traces
remove html and body tags if they are not present in the template
* GSWeb.framework/GSWTemplateParseXML.h: added ivar _isHTMLTag, _isBodyTag
* GSWeb.framework/GSWSessionTimeOutManager.m: dealloc sessionOrderedTimeOuts instead
of deallocating 2 times sessionTimeOuts
* GSWExtensions.framework/French.lproj/GSWSessionRestorationErrorPage.gswc/GSWSessionRestorationErrorPage.html:
tag mismatch, Encode french characters
* GSWExtensions.framework/GSWSessionRestorationErrorPage.gswc/GSWSessionRestorationErrorPage.html:
tag mismatch
* GSWHTMLBareString.m: handle unicode strings in description
* GSWExtensions.framework/French.lproj/GSWExceptionPage.gswc/GSWExceptionPage.html:
Encode french characters, Tag Mismatch
* GSWExtensions.framework/French.lproj/GSWPageRestorationErrorPage.gswc/GSWPageRestorationErrorPage.html:
Encode french characters
* GSWExtensions.framework/French.lproj/GSWSessionCreationErrorPage.gswc/GSWSessionCreationErrorPage.html:
Encode french characters
* GSWExtensions.framework/GSWExceptionPage.gswc/GSWExceptionPage.html:
Tag Mismatch
* GSWExtensions.framework/GSWExceptionPage.gswc/GSWExceptionPage.gswd:
added convertHTMLEntities for strings
* GSWeb.framework/GSWRepetition.m: added traces, fix "count" property bug, standardize ivars
* GSWeb.framework/NSObject+IVarAccess+PerformSel.m: added traces, handle underscored ivars search
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@9332 72102866-910b-0410-8b05-ffd578937521
2001-03-11 17:15:44 +00:00
|
|
|
pHTTPResponse->pszStatusMessage = strdup(g_szOKGSWeb[GSWNAMES_INDEX]);
|
2000-01-22 12:49:49 +00:00
|
|
|
pHTTPResponse->pHeaders=GSWDict_New(2);
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWDict_Add(pHTTPResponse->pHeaders, g_szHeader_ContentType,
|
|
|
|
g_szContentType_TextHtml,FALSE);
|
2000-01-22 12:49:49 +00:00
|
|
|
GSWDict_AddStringDup(pHTTPResponse->pHeaders,"location",p_pszRedirectPath);
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWLog(GSW_DEBUG,p_pLogServerData,
|
|
|
|
"Stop GSWHTTPResponse_BuildRedirectedResponse");
|
2000-01-22 12:49:49 +00:00
|
|
|
return pHTTPResponse;
|
|
|
|
};
|
|
|
|
|
2000-03-16 16:16:49 +00:00
|
|
|
//--------------------------------------------------------------------
|
2003-02-28 18:37:43 +00:00
|
|
|
void
|
|
|
|
GSWHTTPResponse_Free(GSWHTTPResponse *p_pHTTPResponse,
|
|
|
|
void *p_pLogServerData)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWHTTPResponse_Free");
|
2000-01-22 12:49:49 +00:00
|
|
|
if (p_pHTTPResponse)
|
2003-02-28 18:37:43 +00:00
|
|
|
{
|
|
|
|
if (p_pHTTPResponse->pHeaders)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWDict_Free(p_pHTTPResponse->pHeaders);
|
|
|
|
p_pHTTPResponse->pHeaders=NULL;
|
|
|
|
};
|
|
|
|
if (p_pHTTPResponse->pszStatusMessage)
|
|
|
|
{
|
|
|
|
free(p_pHTTPResponse->pszStatusMessage);
|
|
|
|
p_pHTTPResponse->pszStatusMessage=NULL;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
2003-02-28 18:37:43 +00:00
|
|
|
if (p_pHTTPResponse->pContent)
|
|
|
|
{
|
|
|
|
free(p_pHTTPResponse->pContent);
|
|
|
|
p_pHTTPResponse->pContent=NULL;
|
|
|
|
};
|
|
|
|
free(p_pHTTPResponse);
|
|
|
|
p_pHTTPResponse=NULL;
|
|
|
|
};
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWHTTPResponse_Free");
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
2000-03-16 16:16:49 +00:00
|
|
|
//--------------------------------------------------------------------
|
2003-02-28 18:37:43 +00:00
|
|
|
void
|
|
|
|
GSWHTTPResponse_AddHeader(GSWHTTPResponse *p_pHTTPResponse,
|
|
|
|
char *p_pszHeader)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
char *pszKey=NULL;
|
|
|
|
char *pszValue=NULL;
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
for (pszKey=p_pszHeader,pszValue=pszKey;*pszValue!=':';pszValue++)
|
2003-02-28 18:37:43 +00:00
|
|
|
{
|
|
|
|
if (isupper(*pszValue))
|
|
|
|
*pszValue = tolower(*pszValue);
|
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
if (*pszValue==':')
|
2003-02-28 18:37:43 +00:00
|
|
|
{
|
|
|
|
*pszValue++='\0';
|
|
|
|
while (*pszValue && isspace(*pszValue))
|
|
|
|
pszValue++;
|
|
|
|
GSWDict_AddStringDup(p_pHTTPResponse->pHeaders,pszKey,pszValue);
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2003-02-28 18:37:43 +00:00
|
|
|
if (p_pHTTPResponse->uContentLength==0 &&
|
|
|
|
strcmp(g_szHeader_ContentLength,pszKey)==0)
|
|
|
|
p_pHTTPResponse->uContentLength = atoi(pszValue);
|
|
|
|
}
|
2000-01-22 12:49:49 +00:00
|
|
|
else
|
2003-02-28 18:37:43 +00:00
|
|
|
{
|
|
|
|
//TODO PB
|
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
2000-03-16 16:16:49 +00:00
|
|
|
//--------------------------------------------------------------------
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWHTTPResponse *
|
|
|
|
GSWHTTPResponse_GetResponse(AppConnectHandle p_socket,
|
|
|
|
void *p_pLogServerData)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWHTTPResponse *pHTTPResponse=NULL;
|
2000-01-22 12:49:49 +00:00
|
|
|
char szResponseBuffer[RESPONSE__LINE_MAX_SIZE];
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWHTTPResponse_GetResponse");
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
// Get the 1st Line
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWApp_ReceiveLine(p_socket,szResponseBuffer,
|
|
|
|
RESPONSE__LINE_MAX_SIZE,p_pLogServerData);
|
2000-03-16 16:16:49 +00:00
|
|
|
pHTTPResponse = GSWHTTPResponse_New(szResponseBuffer,p_pLogServerData);
|
2000-01-22 12:49:49 +00:00
|
|
|
#ifdef DEBUG
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWLog(GSW_INFO,p_pLogServerData,"Response receive first line:\t\t[%s]",
|
|
|
|
szResponseBuffer);
|
2000-01-22 12:49:49 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!pHTTPResponse) //Error
|
2003-02-28 18:37:43 +00:00
|
|
|
pHTTPResponse=GSWHTTPResponse_BuildErrorResponse(NULL,"Invalid Response",
|
|
|
|
p_pLogServerData);
|
2000-01-22 12:49:49 +00:00
|
|
|
else
|
2003-02-28 18:37:43 +00:00
|
|
|
{
|
|
|
|
int iHeader=0;
|
|
|
|
// Headers
|
|
|
|
while (GSWApp_ReceiveLine(p_socket,szResponseBuffer,
|
|
|
|
RESPONSE__LINE_MAX_SIZE,p_pLogServerData)>0
|
|
|
|
&& szResponseBuffer[0])
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWLog(GSW_INFO,p_pLogServerData,"Header %d=\t\t[%s]",
|
|
|
|
iHeader,szResponseBuffer);
|
2000-01-22 12:49:49 +00:00
|
|
|
#endif
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWHTTPResponse_AddHeader(pHTTPResponse,szResponseBuffer);
|
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
// Content
|
2003-02-28 18:37:43 +00:00
|
|
|
if (pHTTPResponse->uContentLength)
|
|
|
|
{
|
|
|
|
char *pszBuffer= malloc(pHTTPResponse->uContentLength);
|
|
|
|
int iReceivedCount=GSWApp_ReceiveBlock(p_socket,pszBuffer,
|
|
|
|
pHTTPResponse->uContentLength,
|
|
|
|
p_pLogServerData);
|
2000-01-22 12:49:49 +00:00
|
|
|
#ifdef DEBUG
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWLog(GSW_INFO,p_pLogServerData,"iReceivedCount=%d",iReceivedCount);
|
2000-01-22 12:49:49 +00:00
|
|
|
#endif
|
2003-02-28 18:37:43 +00:00
|
|
|
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 !");
|
2001-10-25 Manuel Guesdon <mguesdon@orange-concept.com>
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
2001-10-26 08:50:52 +00:00
|
|
|
|
2003-02-28 18:37:43 +00:00
|
|
|
free(pszBuffer);
|
|
|
|
pszBuffer=NULL;
|
|
|
|
GSWHTTPResponse_Free(pHTTPResponse,p_pLogServerData);
|
|
|
|
pHTTPResponse=NULL;
|
|
|
|
pHTTPResponse = GSWHTTPResponse_BuildErrorResponse(NULL,
|
|
|
|
"Invalid Response",p_pLogServerData);
|
2001-10-25 Manuel Guesdon <mguesdon@orange-concept.com>
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
2001-10-26 08:50:52 +00:00
|
|
|
|
2003-02-28 18:37:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
pHTTPResponse->pContent = pszBuffer;
|
2003-04-05 15:16:56 +00:00
|
|
|
|
|
|
|
#ifdef Apache2
|
|
|
|
if (GSWConfig_AddTimeHeaders())
|
|
|
|
{
|
|
|
|
char *pszBuffer= malloc(100);
|
|
|
|
strcpy(pszBuffer,"gswadaptor-receivedresponsedate: ");
|
|
|
|
FormatAPRTime(pszBuffer+strlen(pszBuffer),apr_time_now());
|
|
|
|
GSWHTTPResponse_AddHeader(pHTTPResponse,
|
|
|
|
pszBuffer);
|
|
|
|
free(pszBuffer);
|
|
|
|
pszBuffer=NULL;
|
|
|
|
};
|
|
|
|
#endif
|
2003-02-28 18:37:43 +00:00
|
|
|
}
|
2000-01-22 12:49:49 +00:00
|
|
|
#ifdef DEBUG
|
2001-10-25 Manuel Guesdon <mguesdon@orange-concept.com>
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
2001-10-26 08:50:52 +00:00
|
|
|
/*
|
2003-02-28 18:37:43 +00:00
|
|
|
if (pHTTPResponse->pContent)
|
|
|
|
{
|
|
|
|
char szTraceBuffer[pHTTPResponse->uContentLength+1];
|
|
|
|
GSWLog(GSW_INFO,p_pLogServerData,"\ncontent (%d Bytes)=\n",
|
|
|
|
pHTTPResponse->uContentLength);
|
|
|
|
memcpy(szTraceBuffer,pHTTPResponse->pContent,
|
|
|
|
pHTTPResponse->uContentLength);
|
|
|
|
szTraceBuffer[pHTTPResponse->uContentLength] = 0;
|
|
|
|
GSWLogSized(GSW_INFO,p_pLogServerData,
|
|
|
|
pHTTPResponse->uContentLength+1,
|
|
|
|
"%.*s",
|
|
|
|
(int)pHTTPResponse->uContentLength,
|
|
|
|
szTraceBuffer);
|
|
|
|
// GSWLog(GSW_INFO,p_pLogServerData,"\nEND\n");
|
|
|
|
};
|
2001-10-25 Manuel Guesdon <mguesdon@orange-concept.com>
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
2001-10-26 08:50:52 +00:00
|
|
|
*/
|
2000-01-22 12:49:49 +00:00
|
|
|
#endif
|
2003-02-28 18:37:43 +00:00
|
|
|
};
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWHTTPResponse_GetResponse");
|
2000-01-22 12:49:49 +00:00
|
|
|
return pHTTPResponse;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-03-16 16:16:49 +00:00
|
|
|
//--------------------------------------------------------------------
|
2003-02-28 18:37:43 +00:00
|
|
|
static void
|
|
|
|
GetHeaderLength(GSWDictElem *p_pElem,
|
|
|
|
void *p_piAddTo)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
int *piAddTo=(int *)p_piAddTo;
|
2000-01-22 12:49:49 +00:00
|
|
|
// +2=": "
|
|
|
|
// +1="\r"
|
|
|
|
// +1="\n"
|
2003-02-28 18:37:43 +00:00
|
|
|
(*piAddTo)+=strlen(p_pElem->pszKey)+strlen((char *)p_pElem->pValue)+2+1+2;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
2000-03-16 16:16:49 +00:00
|
|
|
//--------------------------------------------------------------------
|
2003-02-28 18:37:43 +00:00
|
|
|
static void
|
|
|
|
FormatHeader(GSWDictElem *p_pElem,
|
|
|
|
void *p_ppszBuffer)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
char **ppszBuffer=(char **)p_ppszBuffer;
|
2000-01-22 12:49:49 +00:00
|
|
|
strcpy(*ppszBuffer,p_pElem->pszKey);
|
|
|
|
strcat(*ppszBuffer, ": ");
|
2003-02-28 18:37:43 +00:00
|
|
|
strcat(*ppszBuffer,(char *)p_pElem->pValue);
|
2000-01-22 12:49:49 +00:00
|
|
|
(*ppszBuffer)+= strlen(*ppszBuffer);
|
|
|
|
**ppszBuffer = '\r';
|
|
|
|
(*ppszBuffer)++;
|
|
|
|
**ppszBuffer = '\n';
|
|
|
|
(*ppszBuffer)++;
|
|
|
|
};
|
|
|
|
|
2000-03-16 16:16:49 +00:00
|
|
|
//--------------------------------------------------------------------
|
2003-02-28 18:37:43 +00:00
|
|
|
char *
|
|
|
|
GSWHTTPResponse_PackageHeaders(GSWHTTPResponse *p_pHTTPResponse,
|
|
|
|
char *p_pszBuffer,
|
|
|
|
int p_iBufferSize)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
int iHeaderLength=0;
|
2003-02-28 18:37:43 +00:00
|
|
|
char *pszBuffer=NULL;
|
|
|
|
char *pszTmp=NULL;
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
GSWDict_PerformForAllElem(p_pHTTPResponse->pHeaders,
|
2003-02-28 18:37:43 +00:00
|
|
|
GetHeaderLength,
|
|
|
|
(void *)&iHeaderLength);
|
|
|
|
pszBuffer = ((p_iBufferSize > (iHeaderLength)) ?
|
|
|
|
p_pszBuffer : malloc(p_iBufferSize+1));
|
2000-01-22 12:49:49 +00:00
|
|
|
pszTmp = pszBuffer;
|
|
|
|
|
|
|
|
GSWDict_PerformForAllElem(p_pHTTPResponse->pHeaders,FormatHeader,&pszTmp);
|
|
|
|
*pszTmp = '\0';
|
|
|
|
if (pszTmp-pszBuffer>1)
|
2003-02-28 18:37:43 +00:00
|
|
|
{
|
|
|
|
// Remove last \r\n
|
|
|
|
*(pszTmp-1) = 0;
|
|
|
|
*(pszTmp-2) = 0;
|
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
return pszBuffer;
|
|
|
|
};
|
|
|
|
|
2000-03-16 16:16:49 +00:00
|
|
|
//--------------------------------------------------------------------
|
2003-02-28 18:37:43 +00:00
|
|
|
void
|
|
|
|
GSWHTTPResponse_AddHeaderToString(GSWDictElem *p_pElem,
|
|
|
|
void *p_pData)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWString *pString=(GSWString *)p_pData;
|
2000-01-22 12:49:49 +00:00
|
|
|
GSWString_Append(pString,p_pElem->pszKey);
|
|
|
|
GSWString_Append(pString,": ");
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWString_Append(pString,(char *)p_pElem->pValue);
|
2000-01-22 12:49:49 +00:00
|
|
|
GSWString_Append(pString,"<br>");
|
|
|
|
};
|
|
|
|
|
2000-03-16 16:16:49 +00:00
|
|
|
//--------------------------------------------------------------------
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWHTTPResponse *
|
|
|
|
GSWHTTPResponse_BuildStatusResponse(GSWHTTPRequest *p_pHTTPRequest,
|
|
|
|
void *p_pLogServerData)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWHTTPResponse *pHTTPResponse=
|
|
|
|
GSWHTTPResponse_New(g_szOKStatus[GSWNAMES_INDEX],p_pLogServerData);
|
|
|
|
GSWDict *pRequestHeaders=NULL;
|
|
|
|
GSWString *pContent=GSWString_New();
|
|
|
|
GSWString *pHeadersBuffer=GSWString_New();
|
|
|
|
const char *pszRemoteAddr=NULL;
|
|
|
|
const char *pszRemoteHost=NULL;
|
|
|
|
char *pszString=NULL;
|
|
|
|
|
|
|
|
GSWLog(GSW_DEBUG,p_pLogServerData,
|
|
|
|
"Start GSWHTTPResponse_BuildStatusResponse");
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWLog(GSW_INFO,p_pLogServerData,"Build Status Page.");
|
|
|
|
GSWConfig_LoadConfiguration(p_pLogServerData);
|
2000-01-22 12:49:49 +00:00
|
|
|
GSWDict_AddString(pHTTPResponse->pHeaders,
|
2003-02-28 18:37:43 +00:00
|
|
|
g_szHeader_ContentType,
|
|
|
|
g_szContentType_TextHtml,
|
|
|
|
FALSE);
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2003-02-28 18:37:43 +00:00
|
|
|
pRequestHeaders = (GSWDict *)(p_pHTTPRequest->pHeaders);
|
|
|
|
GSWDict_PerformForAllElem(pRequestHeaders,
|
|
|
|
GSWHTTPResponse_AddHeaderToString,pHeadersBuffer);
|
2000-03-16 16:16:49 +00:00
|
|
|
if (GSWConfig_CanDumpStatus())
|
2001-10-28 10:29:17 +00:00
|
|
|
pszString=GSWTemplate_StatusAllowedResponse(TRUE,NULL);
|
2000-03-16 16:16:49 +00:00
|
|
|
else
|
2001-10-28 10:29:17 +00:00
|
|
|
pszString=GSWTemplate_StatusDeniedResponse(TRUE,NULL);
|
|
|
|
GSWString_Append(pContent,pszString);
|
|
|
|
free(pszString);
|
2003-02-28 18:37:43 +00:00
|
|
|
pszRemoteAddr=(const char *)GSWDict_ValueForKey(pRequestHeaders,
|
|
|
|
"x-gsweb-remote-addr");
|
2000-03-16 16:16:49 +00:00
|
|
|
if (!pszRemoteAddr)
|
2003-02-28 18:37:43 +00:00
|
|
|
pszRemoteAddr="";
|
|
|
|
pszRemoteHost=(const char *)GSWDict_ValueForKey(pRequestHeaders,
|
|
|
|
"x-gsweb-remote-host");
|
2000-03-16 16:16:49 +00:00
|
|
|
if (!pszRemoteHost)
|
2003-02-28 18:37:43 +00:00
|
|
|
pszRemoteHost="";
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWString_SearchReplace(pContent,"##REMOTE_ADDR##",pszRemoteAddr);
|
|
|
|
GSWString_SearchReplace(pContent,"##REMOTE_HOST##",pszRemoteHost);
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWString_SearchReplace(pContent,"##SERVER_INFO##",
|
|
|
|
GSWConfig_ServerStringInfo());
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWString_SearchReplace(pContent,"##SERVER_URL##",GSWConfig_ServerURL());
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWString_SearchReplace(pContent,"##ADAPTOR_INFO##",
|
|
|
|
g_szGSWeb_AdaptorStringInfo());
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWString_SearchReplace(pContent,"##ADAPTOR_URL##",g_szGSWeb_AdaptorURL());
|
|
|
|
GSWString_SearchReplace(pContent,"##HEADERS##",pHeadersBuffer->pszData);
|
|
|
|
GSWTemplate_ReplaceStd(pContent,NULL);
|
|
|
|
GSWString_Free(pHeadersBuffer);
|
|
|
|
pHeadersBuffer=NULL;
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2000-03-16 16:16:49 +00:00
|
|
|
pHTTPResponse->uContentLength = GSWString_Len(pContent);
|
2000-01-22 12:49:49 +00:00
|
|
|
pHTTPResponse->pContent = pContent->pszData;
|
|
|
|
GSWString_Detach(pContent);
|
|
|
|
GSWString_Free(pContent);
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWLog(GSW_DEBUG,p_pLogServerData,
|
|
|
|
"Stop GSWHTTPResponse_BuildStatusResponse");
|
2000-01-22 12:49:49 +00:00
|
|
|
return pHTTPResponse;
|
|
|
|
};
|
|
|
|
|
2000-03-16 16:16:49 +00:00
|
|
|
//--------------------------------------------------------------------
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWHTTPResponse *
|
|
|
|
GSWDumpConfigFile(GSWURLComponents *p_pURLComponents,
|
|
|
|
void *p_pLogServerData)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWHTTPResponse *pHTTPResponse=NULL;
|
|
|
|
GSWString *pContent=NULL;
|
|
|
|
char pszPrefix[MAXPATHLEN]="";
|
|
|
|
char szReqAppName[MAXPATHLEN]="Unknown";
|
|
|
|
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWDumpConfigFile");
|
|
|
|
GSWLog(GSW_INFO,p_pLogServerData,"Creating Applications Page.");
|
|
|
|
if (!g_pszLocalHostName)
|
2003-02-28 18:37:43 +00:00
|
|
|
{
|
|
|
|
char szHostName[MAXHOSTNAMELEN+1];
|
|
|
|
gethostname(szHostName, MAXHOSTNAMELEN);
|
|
|
|
g_pszLocalHostName= strdup(szHostName);
|
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2003-02-28 18:37:43 +00:00
|
|
|
pHTTPResponse = GSWHTTPResponse_New(g_szOKStatus[GSWNAMES_INDEX],
|
|
|
|
p_pLogServerData);
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWDict_AddString(pHTTPResponse->pHeaders,
|
2003-02-28 18:37:43 +00:00
|
|
|
g_szHeader_ContentType,
|
|
|
|
g_szContentType_TextHtml,
|
|
|
|
FALSE);
|
|
|
|
if (p_pURLComponents->stAppName.iLength>0 &&
|
|
|
|
p_pURLComponents->stAppName.pszStart)
|
|
|
|
{
|
|
|
|
strncpy(szReqAppName,p_pURLComponents->stAppName.pszStart,
|
|
|
|
p_pURLComponents->stAppName.iLength);
|
|
|
|
szReqAppName[p_pURLComponents->stAppName.iLength]=0;
|
|
|
|
};
|
2000-03-16 16:16:49 +00:00
|
|
|
|
2003-02-28 18:37:43 +00:00
|
|
|
strncpy(pszPrefix, p_pURLComponents->stPrefix.pszStart,
|
|
|
|
p_pURLComponents->stPrefix.iLength);
|
2000-03-16 16:16:49 +00:00
|
|
|
pszPrefix[p_pURLComponents->stPrefix.iLength] = '\0';
|
|
|
|
|
|
|
|
GSWConfig_LoadConfiguration(p_pLogServerData);
|
2003-02-28 18:37:43 +00:00
|
|
|
pContent=GSWConfig_DumpGSWApps(szReqAppName,pszPrefix,FALSE,TRUE,
|
|
|
|
p_pLogServerData);
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWTemplate_ReplaceStd(pContent,NULL);
|
|
|
|
pHTTPResponse->uContentLength = pContent->iLen;
|
|
|
|
pHTTPResponse->pContent = pContent->pszData;
|
|
|
|
GSWString_Detach(pContent);
|
|
|
|
GSWString_Free(pContent);
|
|
|
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWDumpConfigFile");
|
2000-01-22 12:49:49 +00:00
|
|
|
return pHTTPResponse;
|
|
|
|
};
|