2000-01-22 12:49:49 +00:00
|
|
|
/* mod_gsweb.c - GSWeb: Apache Module
|
2004-11-08 14:15:59 +00:00
|
|
|
Copyright (C) 1999-2004 Free Software Foundation, Inc.
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2004-11-08 14:15:59 +00:00
|
|
|
Written by: Manuel Guesdon <mguesdon@orange-concept.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.
|
|
|
|
*/
|
|
|
|
|
2003-04-04 18:24:19 +00:00
|
|
|
#define moduleRevision "$Revision$"
|
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
|
2013-06-09 08:42:09 +00:00
|
|
|
#include "config.h"
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
#include "GSWUtil.h"
|
2004-12-27 16:33:24 +00:00
|
|
|
#include "GSWStats.h"
|
2000-01-22 12:49:49 +00:00
|
|
|
#include "GSWDict.h"
|
2000-03-16 16:16:49 +00:00
|
|
|
#include "GSWString.h"
|
2000-01-22 12:49:49 +00:00
|
|
|
#include "GSWConfig.h"
|
|
|
|
#include "GSWURLUtil.h"
|
|
|
|
#include "GSWHTTPHeaders.h"
|
|
|
|
|
|
|
|
#include "GSWAppRequestStruct.h"
|
|
|
|
#include "GSWAppConnect.h"
|
|
|
|
#include "GSWHTTPRequest.h"
|
|
|
|
#include "GSWHTTPResponse.h"
|
|
|
|
#include "GSWAppRequest.h"
|
|
|
|
|
|
|
|
#include "httpd.h"
|
|
|
|
#include <http_config.h>
|
|
|
|
#include <http_request.h>
|
|
|
|
#include <http_core.h>
|
|
|
|
|
2002-12-11 21:58:13 +00:00
|
|
|
#include <http_protocol.h>
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
// Module Definition:
|
|
|
|
|
|
|
|
// Declare the module
|
2005-05-09 12:20:18 +00:00
|
|
|
module gsweb_module;
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
typedef struct _GSWeb_Config
|
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
const char *pszGSWeb; // default = GSWeb
|
|
|
|
const char *pszConfigPath; // path to GSWeb.conf
|
|
|
|
// const char *pszRoot; // normally htdocs/GSWeb
|
2000-01-22 12:49:49 +00:00
|
|
|
} GSWeb_Config;
|
|
|
|
|
2003-04-04 18:24:19 +00:00
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
//TODO: remove ??
|
|
|
|
struct table
|
|
|
|
{
|
|
|
|
/* This has to be first to promote backwards compatibility with
|
2003-02-28 18:37:43 +00:00
|
|
|
* older modules which cast a table * to an array_header *...
|
|
|
|
* they should use the table_elts() function for most of the
|
|
|
|
* cases they do this for.
|
|
|
|
*/
|
2000-01-22 12:49:49 +00:00
|
|
|
array_header a;
|
|
|
|
#ifdef MAKE_TABLE_PROFILE
|
|
|
|
void *creator;
|
|
|
|
#endif
|
|
|
|
};
|
2003-04-04 18:24:19 +00:00
|
|
|
|
2003-02-28 18:37:43 +00:00
|
|
|
/*
|
|
|
|
static CONST char *GSWeb_SetDocRoot(cmd_parms *p_pCmdParams,
|
|
|
|
void *p_pUnused,
|
|
|
|
char *p_pszArg);
|
|
|
|
*/
|
|
|
|
static CONST char *GSWeb_SetScriptAlias(cmd_parms *p_pCmdParams,
|
|
|
|
void *p_pUnused,
|
|
|
|
char *p_pszArg);
|
|
|
|
static CONST char *GSWeb_SetConfig(cmd_parms *p_pCmdParams,
|
|
|
|
void *p_pUnused,
|
|
|
|
char *p_pszArg);
|
|
|
|
static int GSWeb_Handler(request_rec *p_pRequestRec);
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2002-12-11 21:58:13 +00:00
|
|
|
/*
|
|
|
|
* Locate our server configuration record for the current request.
|
|
|
|
*/
|
2003-02-28 18:37:43 +00:00
|
|
|
static GSWeb_Config *
|
|
|
|
GSWeb_GetServerConfig(server_rec *p_pServerRec)
|
2002-12-11 21:58:13 +00:00
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
return (GSWeb_Config *)ap_get_module_config(p_pServerRec->module_config,
|
2005-05-09 12:20:18 +00:00
|
|
|
&gsweb_module);
|
2002-12-11 21:58:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// Init
|
2003-02-28 18:37:43 +00:00
|
|
|
static void
|
|
|
|
GSWeb_Init(server_rec *p_pServerRec,
|
|
|
|
pool *p)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWDict *pDict=GSWDict_New(0);
|
|
|
|
GSWeb_Config *pConfig=NULL;
|
|
|
|
|
2002-12-11 21:58:13 +00:00
|
|
|
pConfig=GSWeb_GetServerConfig(p_pServerRec);
|
2000-01-22 12:49:49 +00:00
|
|
|
GSWLog_Init(NULL,GSW_INFO);
|
2006-12-19 22:41:28 +00:00
|
|
|
GSWLog(__FILE__, __LINE__,GSW_INFO,p_pServerRec,
|
2003-02-28 18:37:43 +00:00
|
|
|
"GSWeb Init Start Config. Handler: " GSWEB_HANDLER);
|
2004-12-27 16:33:24 +00:00
|
|
|
GSWDebugLog(p_pServerRec,
|
2003-02-28 18:37:43 +00:00
|
|
|
"GSWeb_Init: pConfig->pszGSWeb=%s",
|
|
|
|
pConfig->pszGSWeb);
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
if (pConfig && pConfig->pszConfigPath)
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWDict_AddStringDup(pDict,
|
|
|
|
g_szGSWeb_Conf_ConfigFilePath,
|
|
|
|
pConfig->pszConfigPath);
|
|
|
|
/*
|
|
|
|
if (pConfig && pConfig->pszRoot)
|
|
|
|
GSWDict_AddStringDup(pDict,
|
|
|
|
g_szGSWeb_Conf_DocRoot,
|
|
|
|
pConfig->pszRoot);
|
|
|
|
*/
|
2006-12-19 22:41:28 +00:00
|
|
|
GSWLog(__FILE__, __LINE__,GSW_INFO,p_pServerRec,
|
2003-02-28 18:37:43 +00:00
|
|
|
"GSWeb Init LB Init. Handler: " GSWEB_HANDLER);
|
2000-08-25 10:36:16 +00:00
|
|
|
GSWConfig_Init(pDict,p_pServerRec);
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2006-12-19 22:41:28 +00:00
|
|
|
GSWLog(__FILE__, __LINE__,GSW_INFO,p_pServerRec,
|
2003-02-28 18:37:43 +00:00
|
|
|
"GSWeb Init. Handler: " GSWEB_HANDLER);
|
2000-01-22 12:49:49 +00:00
|
|
|
GSWDict_Free(pDict);
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// Create Config
|
2003-02-28 18:37:43 +00:00
|
|
|
static void *
|
|
|
|
GSWeb_CreateServerConfig(pool *p_pPool,
|
|
|
|
server_rec *p_pServerRec)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWeb_Config *pConfig = (GSWeb_Config *)ap_palloc(p_pPool,
|
|
|
|
sizeof(GSWeb_Config));
|
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
pConfig->pszGSWeb = g_szGSWeb_Prefix;
|
2004-12-27 16:33:24 +00:00
|
|
|
GSWDebugLog(p_pServerRec,
|
2003-02-28 18:37:43 +00:00
|
|
|
"GSWeb_CreateServerConfig: pConfig->pszGSWeb=%s",
|
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
|
|
|
pConfig->pszGSWeb);
|
2000-01-22 12:49:49 +00:00
|
|
|
pConfig->pszConfigPath = NULL;
|
2000-03-16 16:16:49 +00:00
|
|
|
// pConfig->pszRoot = NULL;
|
2000-01-22 12:49:49 +00:00
|
|
|
return pConfig;
|
|
|
|
};
|
2000-03-16 16:16:49 +00:00
|
|
|
/*
|
2000-01-22 12:49:49 +00:00
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// Set Param: DocRoot
|
2003-02-28 18:37:43 +00:00
|
|
|
static CONST char *
|
|
|
|
GSWeb_SetDocRoot(cmd_parms *p_pCmdParams,
|
|
|
|
void *p_pUnused,
|
|
|
|
char *p_pszArg)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
server_rec *pServerRec = p_pCmdParams->server;
|
|
|
|
GSWeb_Config *pConfig = NULL;
|
|
|
|
|
2004-12-27 16:33:24 +00:00
|
|
|
GSWDebugLog(pServerRec,"Start GSWeb_SetDocRoot");
|
2003-02-28 18:37:43 +00:00
|
|
|
pConfig=(GSWeb_Config *)ap_get_module_config(pServerRec->module_config,
|
2005-05-09 12:20:18 +00:00
|
|
|
&gsweb_module);
|
2003-02-28 18:37:43 +00:00
|
|
|
pConfig->pszRoot = p_pszArg;
|
2004-12-27 16:33:24 +00:00
|
|
|
GSWDebugLog(pServerRec,"Start GSWeb_SetDocRoot");
|
2003-02-28 18:37:43 +00:00
|
|
|
return NULL;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
2000-03-16 16:16:49 +00:00
|
|
|
*/
|
2000-01-22 12:49:49 +00:00
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// Set Param: ScriptAlias
|
2003-02-28 18:37:43 +00:00
|
|
|
static CONST char *
|
|
|
|
GSWeb_SetScriptAlias(cmd_parms *p_pCmdParams,
|
|
|
|
void *p_pUnused,
|
|
|
|
char *p_pszArg)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
server_rec *pServerRec = p_pCmdParams->server;
|
|
|
|
GSWeb_Config *pConfig = NULL;
|
2004-12-27 16:33:24 +00:00
|
|
|
GSWDebugLog(pServerRec,"Start GSWeb_SetScriptAlias");
|
2002-12-11 21:58:13 +00:00
|
|
|
pConfig=GSWeb_GetServerConfig(pServerRec);
|
2000-01-22 12:49:49 +00:00
|
|
|
pConfig->pszGSWeb = p_pszArg;
|
2004-12-27 16:33:24 +00:00
|
|
|
GSWDebugLog(pServerRec,"Stop GSWeb_SetScriptAlias");
|
2000-01-22 12:49:49 +00:00
|
|
|
return NULL;
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// Set Param: ConfigFile
|
2003-02-28 18:37:43 +00:00
|
|
|
static CONST char *
|
|
|
|
GSWeb_SetConfig(cmd_parms *p_pCmdParams,
|
|
|
|
void *p_pUnused,
|
|
|
|
char *p_pszArg)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
server_rec *pServerRec = p_pCmdParams->server;
|
|
|
|
GSWeb_Config *pConfig = NULL;
|
|
|
|
|
2004-12-27 16:33:24 +00:00
|
|
|
GSWDebugLog(pServerRec,"Start GSWeb_SetConfig");
|
2002-12-11 21:58:13 +00:00
|
|
|
pConfig=GSWeb_GetServerConfig(pServerRec);
|
2004-12-27 16:33:24 +00:00
|
|
|
GSWDebugLog(pServerRec,"pConfig=%p",pConfig);
|
|
|
|
GSWDebugLog(pServerRec,"p_pszArg=%s",p_pszArg);
|
2000-01-22 12:49:49 +00:00
|
|
|
pConfig->pszConfigPath = p_pszArg;
|
2004-12-27 16:33:24 +00:00
|
|
|
GSWDebugLog(pServerRec,"Stop GSWeb_SetConfig");
|
2000-01-22 12:49:49 +00:00
|
|
|
return NULL;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// Translate
|
2003-02-28 18:37:43 +00:00
|
|
|
int
|
|
|
|
GSWeb_Translation(request_rec *p_pRequestRec)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
int iRetValue=OK;
|
|
|
|
GSWeb_Config *pConfig=NULL;
|
|
|
|
GSWURLComponents stURL;
|
|
|
|
|
2000-03-16 16:16:49 +00:00
|
|
|
memset(&stURL,0,sizeof(stURL));
|
2004-12-27 16:33:24 +00:00
|
|
|
GSWDebugLog(p_pRequestRec->server,"Start GSWeb_Translation");
|
2002-12-11 21:58:13 +00:00
|
|
|
pConfig=GSWeb_GetServerConfig(p_pRequestRec->server);
|
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
// Is this for us ?
|
|
|
|
if (strncmp(pConfig->pszGSWeb,
|
2003-02-28 18:37:43 +00:00
|
|
|
p_pRequestRec->uri,
|
|
|
|
strlen(pConfig->pszGSWeb))==0)
|
|
|
|
{
|
|
|
|
GSWURLError eError=GSWParseURL(&stURL,p_pRequestRec->uri,
|
|
|
|
p_pRequestRec->server);
|
|
|
|
if (eError!=GSWURLError_OK)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2006-12-19 22:41:28 +00:00
|
|
|
GSWLog(__FILE__, __LINE__,GSW_ERROR,p_pRequestRec->server,
|
2003-02-28 18:37:43 +00:00
|
|
|
"GSWeb_Translation Declined (Error %d)",(int)eError);
|
|
|
|
iRetValue=DECLINED;
|
2000-01-22 12:49:49 +00:00
|
|
|
}
|
2003-02-28 18:37:43 +00:00
|
|
|
else
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2004-12-27 16:33:24 +00:00
|
|
|
GSWDebugLog(
|
2003-02-28 18:37:43 +00:00
|
|
|
p_pRequestRec->server,
|
|
|
|
"GSWeb_Translation Handler p_pRequestRec->handler=%s pool=%p handler=%s pConfig->pszGSWeb=%s",
|
|
|
|
p_pRequestRec->handler,
|
|
|
|
p_pRequestRec->pool,
|
|
|
|
g_szGSWeb_Handler,
|
|
|
|
pConfig->pszGSWeb);
|
|
|
|
p_pRequestRec->handler=(char *)ap_pstrdup(p_pRequestRec->pool,
|
|
|
|
g_szGSWeb_Handler);
|
|
|
|
iRetValue=OK;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
2003-02-28 18:37:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-12-27 16:33:24 +00:00
|
|
|
GSWDebugLog(p_pRequestRec->server,"GSWeb_Translation Declined");
|
2003-02-28 18:37:43 +00:00
|
|
|
iRetValue=DECLINED;
|
|
|
|
};
|
2004-12-27 16:33:24 +00:00
|
|
|
GSWDebugLog(p_pRequestRec->server,
|
2003-02-28 18:37:43 +00:00
|
|
|
"Stop GSWeb_Translation return %d",
|
|
|
|
iRetValue);
|
2000-01-22 12:49:49 +00:00
|
|
|
return iRetValue;
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2003-04-05 15:16:56 +00:00
|
|
|
// Copy p_pRequestRec in headers into p_pGSWHTTPRequest
|
|
|
|
// Also add some environment variable headers
|
2003-02-28 18:37:43 +00:00
|
|
|
static void
|
|
|
|
copyHeaders(request_rec *p_pRequestRec,
|
|
|
|
GSWHTTPRequest *p_pGSWHTTPRequest)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
server_rec *pServerRec = p_pRequestRec->server;
|
|
|
|
conn_rec *pConnection = p_pRequestRec->connection;
|
2002-12-11 21:58:13 +00:00
|
|
|
const array_header *headers_arr=ap_table_elts(p_pRequestRec->headers_in);
|
2003-02-28 18:37:43 +00:00
|
|
|
table_entry *headers=NULL;
|
2003-04-04 18:24:19 +00:00
|
|
|
int i=0;
|
|
|
|
char *pszPort=NULL;
|
2003-02-28 18:37:43 +00:00
|
|
|
CONST char *pszRemoteLogName=NULL;
|
2004-12-27 16:33:24 +00:00
|
|
|
GSWDebugLog(pServerRec,"Start copyHeaders");
|
2003-04-05 15:16:56 +00:00
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
// copy p_pRequestRec headers
|
2002-12-11 21:58:13 +00:00
|
|
|
headers = (table_entry *) headers_arr->elts;
|
|
|
|
for (i=0;i<headers_arr->nelts;i++)
|
|
|
|
{
|
|
|
|
if (headers[i].key)
|
2003-04-19 18:55:05 +00:00
|
|
|
{
|
2004-12-27 16:33:24 +00:00
|
|
|
GSWDebugLog(pServerRec,"key=%s value=%s",
|
|
|
|
headers[i].key,headers[i].val);
|
2003-11-26 13:35:43 +00:00
|
|
|
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
|
|
|
headers[i].key,headers[i].val);
|
2003-04-19 18:55:05 +00:00
|
|
|
};
|
2002-12-11 21:58:13 +00:00
|
|
|
};
|
2003-04-04 18:24:19 +00:00
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
// Add server headers
|
|
|
|
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
2002-12-11 21:58:13 +00:00
|
|
|
g_szServerInfo_ServerSoftware,
|
|
|
|
SERVER_VERSION
|
2003-04-04 18:24:19 +00:00
|
|
|
);
|
|
|
|
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
|
|
|
g_szServerInfo_RequestScheme,
|
|
|
|
ap_http_method(p_pRequestRec));
|
|
|
|
|
|
|
|
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
|
|
|
g_szServerInfo_Protocol,
|
|
|
|
p_pRequestRec->protocol);
|
|
|
|
|
|
|
|
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
|
|
|
g_szServerInfo_ProtocolNum,
|
2013-06-06 15:01:40 +00:00
|
|
|
ap_psprintf(p_pRequestRec->pool,
|
2003-04-04 18:24:19 +00:00
|
|
|
"%u",
|
|
|
|
p_pRequestRec->proto_num));
|
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
2002-12-11 21:58:13 +00:00
|
|
|
g_szServerInfo_ServerName,
|
|
|
|
pServerRec->server_hostname);
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2003-04-09 12:03:17 +00:00
|
|
|
{
|
|
|
|
unsigned int serverPort=(unsigned)ap_get_server_port(p_pRequestRec);
|
|
|
|
if (serverPort==0)
|
|
|
|
{
|
|
|
|
if (p_pRequestRec->parsed_uri.port_str && p_pRequestRec->parsed_uri.port!=0)
|
|
|
|
serverPort=(unsigned)p_pRequestRec->parsed_uri.port;
|
|
|
|
else
|
|
|
|
serverPort=(unsigned)pServerRec->port;
|
|
|
|
};
|
2013-06-06 15:01:40 +00:00
|
|
|
pszPort = ap_psprintf(p_pRequestRec->pool,
|
2003-04-09 12:03:17 +00:00
|
|
|
"%u",
|
|
|
|
(unsigned int)serverPort);
|
|
|
|
};
|
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
2002-12-11 21:58:13 +00:00
|
|
|
g_szServerInfo_ServerPort,
|
2003-04-04 18:24:19 +00:00
|
|
|
pszPort);
|
2000-01-22 12:49:49 +00:00
|
|
|
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
2002-12-11 21:58:13 +00:00
|
|
|
g_szServerInfo_RemoteHost,
|
2003-02-28 18:37:43 +00:00
|
|
|
(CONST char *)ap_get_remote_host(pConnection,
|
|
|
|
p_pRequestRec->per_dir_config,
|
|
|
|
REMOTE_NAME));
|
2002-12-11 21:58:13 +00:00
|
|
|
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
|
|
|
g_szServerInfo_RemoteAddress,
|
|
|
|
pConnection->remote_ip);
|
2000-01-22 12:49:49 +00:00
|
|
|
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
2002-12-11 21:58:13 +00:00
|
|
|
g_szServerInfo_DocumentRoot,
|
2003-02-28 18:37:43 +00:00
|
|
|
(char *)ap_document_root(p_pRequestRec));
|
2000-01-22 12:49:49 +00:00
|
|
|
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
2002-12-11 21:58:13 +00:00
|
|
|
g_szServerInfo_ServerAdmin,
|
|
|
|
pServerRec->server_admin);
|
2000-01-22 12:49:49 +00:00
|
|
|
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
2002-12-11 21:58:13 +00:00
|
|
|
g_szServerInfo_ScriptFileName,
|
|
|
|
p_pRequestRec->filename);
|
2013-05-31 16:54:17 +00:00
|
|
|
#if 0
|
2013-06-06 15:01:40 +00:00
|
|
|
pszPort = ap_psprintf(p_pRequestRec->pool,
|
2003-04-04 18:24:19 +00:00
|
|
|
"%u",
|
|
|
|
ntohs(pConnection->remote_addr.sin_port)
|
|
|
|
);
|
2000-01-22 12:49:49 +00:00
|
|
|
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
2002-12-11 21:58:13 +00:00
|
|
|
g_szServerInfo_RemotePort,
|
2003-04-04 18:24:19 +00:00
|
|
|
pszPort);
|
2013-05-31 16:54:17 +00:00
|
|
|
#endif
|
2002-12-11 21:58:13 +00:00
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
if (pConnection->user)
|
2002-12-11 21:58:13 +00:00
|
|
|
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
|
|
|
g_szServerInfo_RemoteUser,
|
|
|
|
pConnection->user);
|
2000-01-22 12:49:49 +00:00
|
|
|
if (pConnection->ap_auth_type)
|
2002-12-11 21:58:13 +00:00
|
|
|
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
|
|
|
g_szServerInfo_AuthType,//"auth_type",
|
|
|
|
pConnection->ap_auth_type);
|
2003-02-28 18:37:43 +00:00
|
|
|
pszRemoteLogName = (char *)ap_get_remote_logname(p_pRequestRec);
|
2000-01-22 12:49:49 +00:00
|
|
|
if (pszRemoteLogName)
|
2002-12-11 21:58:13 +00:00
|
|
|
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
|
|
|
g_szServerInfo_RemoteIdent,
|
|
|
|
pszRemoteLogName);
|
2004-12-27 16:33:24 +00:00
|
|
|
GSWDebugLog(pServerRec,"Stop copyHeaders");
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2003-03-21 14:32:57 +00:00
|
|
|
// callback fonction to copy an header into p_pRequest
|
2003-02-28 18:37:43 +00:00
|
|
|
static void
|
|
|
|
getHeader(GSWDictElem *p_pElem,
|
|
|
|
void *p_pRequestRec)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
request_rec *pRequestRec = (request_rec *)p_pRequestRec;
|
2003-03-21 14:32:57 +00:00
|
|
|
server_rec *pServerRec = pRequestRec->server;
|
2004-12-27 16:33:24 +00:00
|
|
|
|
|
|
|
GSWDebugLog(pServerRec,"Start getHeader key=%s value=%s headers_out=%p",
|
|
|
|
p_pElem->pszKey,(char *)p_pElem->pValue,pRequestRec->headers_out);
|
|
|
|
|
2003-02-28 18:37:43 +00:00
|
|
|
if (!pRequestRec->content_type &&
|
|
|
|
strcasecmp(p_pElem->pszKey,g_szHeader_ContentType)==0)
|
2003-03-21 14:32:57 +00:00
|
|
|
{
|
|
|
|
pRequestRec->content_type = (char *)ap_pstrdup(pRequestRec->pool,
|
|
|
|
(char *)p_pElem->pValue);//TODOVERIFY: strdup or not ?
|
|
|
|
}
|
2000-01-22 12:49:49 +00:00
|
|
|
else
|
2003-02-28 18:37:43 +00:00
|
|
|
ap_table_add(pRequestRec->headers_out,p_pElem->pszKey,
|
|
|
|
(char *)p_pElem->pValue);
|
2004-12-27 16:33:24 +00:00
|
|
|
|
|
|
|
GSWDebugLog(pServerRec,"Stop getHeader");
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// send response
|
|
|
|
|
2003-02-28 18:37:43 +00:00
|
|
|
static void
|
|
|
|
sendResponse(request_rec *p_pRequestRec,
|
|
|
|
GSWHTTPResponse *p_pHTTPResponse)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
server_rec *pServerRec = p_pRequestRec->server;
|
2004-12-27 16:33:24 +00:00
|
|
|
|
|
|
|
GSWDebugLog(pServerRec,"Start sendResponse");
|
|
|
|
|
|
|
|
p_pHTTPResponse->pStats->_responseLength=p_pHTTPResponse->uContentLength;
|
|
|
|
p_pHTTPResponse->pStats->_responseStatus=p_pHTTPResponse->uStatus;
|
|
|
|
|
|
|
|
p_pHTTPResponse->pStats->_prepareSendResponseTS=GSWTime_now();
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
// Process Headers
|
|
|
|
GSWDict_PerformForAllElem(p_pHTTPResponse->pHeaders,getHeader,p_pRequestRec);
|
|
|
|
|
2004-12-27 16:33:24 +00:00
|
|
|
GSWDebugLog(pServerRec,"status message=[%s]",p_pHTTPResponse->pszStatusMessage);
|
2013-06-06 15:01:40 +00:00
|
|
|
p_pRequestRec->status_line = ap_psprintf(p_pRequestRec->pool,"%u %s",
|
2003-03-21 14:32:57 +00:00
|
|
|
p_pHTTPResponse->uStatus,
|
|
|
|
p_pHTTPResponse->pszStatusMessage);
|
2003-04-04 18:24:19 +00:00
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
p_pRequestRec->status = p_pHTTPResponse->uStatus;
|
2004-12-27 16:33:24 +00:00
|
|
|
GSWDebugLog(pServerRec,"p_pRequestRec->status_line=[%s]",p_pRequestRec->status_line);
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
// Set content type if none
|
|
|
|
if (!p_pRequestRec->content_type)
|
2003-03-21 14:32:57 +00:00
|
|
|
{
|
|
|
|
p_pRequestRec->content_type = g_szContentType_TextHtml;
|
|
|
|
};
|
2004-12-27 16:33:24 +00:00
|
|
|
GSWDebugLog(pServerRec,"p_pRequestRec->content_type=%s",p_pRequestRec->content_type);
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
// Set content length
|
2003-03-23 12:29:39 +00:00
|
|
|
ap_set_content_length(p_pRequestRec, p_pHTTPResponse->uContentLength);
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
// Now Send response...
|
|
|
|
|
2004-12-27 16:33:24 +00:00
|
|
|
p_pHTTPResponse->pStats->_beginSendResponseTS=GSWTime_now();
|
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
// send Headers
|
|
|
|
ap_send_http_header(p_pRequestRec);
|
|
|
|
|
|
|
|
// If not headers only
|
|
|
|
if (!p_pRequestRec->header_only)
|
2003-02-28 18:37:43 +00:00
|
|
|
{
|
|
|
|
ap_soft_timeout("Send GSWeb response",p_pRequestRec);
|
|
|
|
ap_rwrite(p_pHTTPResponse->pContent,p_pHTTPResponse->uContentLength,
|
|
|
|
p_pRequestRec);
|
|
|
|
ap_kill_timeout(p_pRequestRec);
|
|
|
|
};
|
2004-12-27 16:33:24 +00:00
|
|
|
|
|
|
|
p_pHTTPResponse->pStats->_endSendResponseTS=GSWTime_now();
|
|
|
|
|
|
|
|
GSWDebugLog(pServerRec,"Stop sendResponse");
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// die/send response
|
2003-02-28 18:37:43 +00:00
|
|
|
static int
|
|
|
|
dieSendResponse(request_rec *p_pRequestRec,
|
2004-12-27 16:33:24 +00:00
|
|
|
GSWTimeStats *p_pStats,
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWHTTPResponse **p_ppHTTPResponse,
|
|
|
|
BOOL p_fDecline)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
server_rec *pServerRec = p_pRequestRec->server;
|
|
|
|
void *pLogServerData=pServerRec;
|
|
|
|
|
2004-12-27 16:33:24 +00:00
|
|
|
GSWDebugLog(pLogServerData,"Start dieSendResponse");
|
2000-01-22 12:49:49 +00:00
|
|
|
sendResponse(p_pRequestRec,*p_ppHTTPResponse);
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWHTTPResponse_Free(*p_ppHTTPResponse,pLogServerData);
|
2000-01-22 12:49:49 +00:00
|
|
|
*p_ppHTTPResponse=NULL;
|
2004-12-27 16:33:24 +00:00
|
|
|
GSWDebugLog(pLogServerData,"Start dieSendResponse");
|
2000-01-22 12:49:49 +00:00
|
|
|
return p_fDecline ? DECLINED : OK;
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// die with a message
|
2003-02-28 18:37:43 +00:00
|
|
|
static int
|
|
|
|
dieWithMessage(request_rec *p_pRequestRec,
|
2004-12-27 16:33:24 +00:00
|
|
|
GSWTimeStats *p_pStats,
|
2003-02-28 18:37:43 +00:00
|
|
|
CONST char *p_pszMessage,
|
|
|
|
BOOL p_fDecline)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2000-03-16 16:16:49 +00:00
|
|
|
int iReturn=0;
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWHTTPResponse *pResponse=NULL;
|
|
|
|
server_rec *pServerRec = p_pRequestRec->server;
|
|
|
|
|
2004-12-27 16:33:24 +00:00
|
|
|
GSWDebugLog(pServerRec,"Start dieWithMessage");
|
2006-12-19 22:41:28 +00:00
|
|
|
GSWLog(__FILE__, __LINE__,GSW_ERROR,pServerRec,"Send Error Response: %s",p_pszMessage);
|
2004-12-27 16:33:24 +00:00
|
|
|
|
2004-11-08 14:15:59 +00:00
|
|
|
pResponse = GSWHTTPResponse_BuildErrorResponse(NULL,
|
2004-12-27 16:33:24 +00:00
|
|
|
p_pStats,
|
2004-11-08 14:15:59 +00:00
|
|
|
200, // Status
|
|
|
|
NULL, // Headers
|
|
|
|
&GSWTemplate_ErrorResponse, // Template
|
|
|
|
p_pszMessage, // Message
|
2003-02-28 18:37:43 +00:00
|
|
|
p_pRequestRec->server);
|
2004-12-27 16:33:24 +00:00
|
|
|
|
|
|
|
iReturn=dieSendResponse(p_pRequestRec,p_pStats,
|
|
|
|
&pResponse,p_fDecline);
|
|
|
|
|
|
|
|
GSWDebugLog(pServerRec,"Stop dieWithMessage");
|
2000-03-16 16:16:49 +00:00
|
|
|
return iReturn;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// GSWeb Request Handler
|
2003-02-28 18:37:43 +00:00
|
|
|
static int
|
|
|
|
GSWeb_Handler(request_rec *p_pRequestRec)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
int iRetVal=OK;
|
|
|
|
GSWURLComponents stURLComponents;
|
|
|
|
GSWHTTPResponse *pResponse = NULL;
|
|
|
|
GSWURLError eError=GSWURLError_OK;
|
|
|
|
CONST char *pszURLError=NULL;
|
|
|
|
server_rec *pServerRec = p_pRequestRec->server;
|
|
|
|
void *pLogServerData=pServerRec;
|
|
|
|
GSWeb_Config *pConfig=NULL;
|
2004-12-27 16:33:24 +00:00
|
|
|
GSWTimeStats stStats;
|
|
|
|
|
|
|
|
memset(&stStats,0,sizeof(stStats));
|
2002-12-11 21:58:13 +00:00
|
|
|
|
2004-12-27 16:33:24 +00:00
|
|
|
// The request time stamp
|
2013-06-09 08:14:21 +00:00
|
|
|
stStats._requestTS=(GSWTime)(p_pRequestRec->request_time);
|
2004-12-27 16:33:24 +00:00
|
|
|
|
|
|
|
// Handling start time stamp
|
|
|
|
stStats._beginHandleRequestTS=GSWTime_now();
|
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
memset(&stURLComponents,0,sizeof(stURLComponents));
|
2004-12-27 16:33:24 +00:00
|
|
|
|
|
|
|
// We'll load config soon to set debug flag
|
|
|
|
if (!GSWConfig_IsReaden())
|
|
|
|
GSWConfig_LoadConfiguration(pLogServerData);
|
|
|
|
|
|
|
|
GSWDebugLog(pLogServerData,"Start GSWeb_Handler");
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2002-12-11 21:58:13 +00:00
|
|
|
pConfig=GSWeb_GetServerConfig(p_pRequestRec->server);
|
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
// Log the request
|
2006-12-19 22:41:28 +00:00
|
|
|
GSWLog(__FILE__, __LINE__,GSW_INFO,
|
2003-02-28 18:37:43 +00:00
|
|
|
pLogServerData,
|
|
|
|
"GNUstepWeb New request: %s",
|
|
|
|
p_pRequestRec->uri);
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2002-12-11 21:58:13 +00:00
|
|
|
// Is this for us ?
|
|
|
|
if (strncmp(pConfig->pszGSWeb,
|
|
|
|
p_pRequestRec->uri,
|
|
|
|
strlen(pConfig->pszGSWeb))==0)
|
|
|
|
{
|
|
|
|
// Parse the uri
|
2004-12-27 16:33:24 +00:00
|
|
|
eError=GSWParseURL(&stURLComponents,
|
|
|
|
p_pRequestRec->uri,
|
2002-12-11 21:58:13 +00:00
|
|
|
pLogServerData);
|
|
|
|
if (eError!=GSWURLError_OK)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2000-03-16 16:16:49 +00:00
|
|
|
pszURLError=GSWURLErrorMessage(eError,
|
2002-12-11 21:58:13 +00:00
|
|
|
pLogServerData);
|
2006-12-19 22:41:28 +00:00
|
|
|
GSWLog(__FILE__, __LINE__,GSW_INFO,pLogServerData,"URL Parsing Error: %s", pszURLError);
|
2000-03-16 16:16:49 +00:00
|
|
|
if (eError==GSWURLError_InvalidAppName)
|
2002-12-11 21:58:13 +00:00
|
|
|
{
|
2004-12-27 16:33:24 +00:00
|
|
|
pResponse = GSWDumpConfigFile(&stStats,
|
|
|
|
&stURLComponents,
|
2002-12-11 21:58:13 +00:00
|
|
|
p_pRequestRec->server);
|
2004-12-27 16:33:24 +00:00
|
|
|
iRetVal=dieSendResponse(p_pRequestRec,&stStats,
|
|
|
|
&pResponse,NO);
|
2002-12-11 21:58:13 +00:00
|
|
|
}
|
2000-01-22 12:49:49 +00:00
|
|
|
else
|
2004-12-27 16:33:24 +00:00
|
|
|
iRetVal=dieWithMessage(p_pRequestRec,
|
|
|
|
&stStats,
|
|
|
|
pszURLError,NO);
|
2000-01-22 12:49:49 +00:00
|
|
|
}
|
2002-12-11 21:58:13 +00:00
|
|
|
else
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
iRetVal = ap_setup_client_block(p_pRequestRec,REQUEST_CHUNKED_ERROR);
|
|
|
|
if (iRetVal==0) // OK Continue
|
2002-12-11 21:58:13 +00:00
|
|
|
{
|
|
|
|
// Build the GSWHTTPRequest with the method
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWHTTPRequest *pRequest=NULL;
|
|
|
|
CONST char *pszRequestError=NULL;
|
2002-12-11 21:58:13 +00:00
|
|
|
|
2004-12-27 16:33:24 +00:00
|
|
|
pRequest=GSWHTTPRequest_New(p_pRequestRec->method,
|
|
|
|
NULL,
|
|
|
|
&stStats,
|
2003-02-28 18:37:43 +00:00
|
|
|
pLogServerData);
|
2002-12-11 21:58:13 +00:00
|
|
|
|
|
|
|
// validate the method
|
2003-02-28 18:37:43 +00:00
|
|
|
pszRequestError=GSWHTTPRequest_ValidateMethod(pRequest,
|
|
|
|
pLogServerData);
|
2002-12-11 21:58:13 +00:00
|
|
|
if (pszRequestError)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2004-12-27 16:33:24 +00:00
|
|
|
iRetVal=dieWithMessage(p_pRequestRec,&stStats,
|
|
|
|
pszRequestError,NO);
|
2002-12-11 21:58:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
CONST char *pszDocRoot=NULL;
|
2003-06-25 14:43:50 +00:00
|
|
|
char* applicationName=NULL;
|
|
|
|
if (stURLComponents.stAppName.pszStart)
|
2003-11-26 13:35:43 +00:00
|
|
|
applicationName=gsw_strndup(stURLComponents.stAppName.pszStart,
|
|
|
|
stURLComponents.stAppName.iLength);//We'll need to release it
|
2003-06-25 14:43:50 +00:00
|
|
|
|
2002-12-11 21:58:13 +00:00
|
|
|
// copy headers
|
|
|
|
copyHeaders(p_pRequestRec,pRequest);
|
2003-06-25 14:43:50 +00:00
|
|
|
|
|
|
|
if (applicationName)
|
|
|
|
GSWHTTPRequest_AddHeader(pRequest,
|
|
|
|
g_szHeader_GSWeb_ApplicationName,
|
|
|
|
applicationName);
|
2002-12-11 21:58:13 +00:00
|
|
|
// Get Form data if any
|
|
|
|
// POST Method
|
|
|
|
if (pRequest->eMethod==ERequestMethod_Post
|
|
|
|
&& pRequest->uContentLength>0
|
|
|
|
&& ap_should_client_block(p_pRequestRec))
|
|
|
|
{
|
2005-12-19 11:05:35 +00:00
|
|
|
long iReadLength=0;
|
2013-05-31 16:54:17 +00:00
|
|
|
|
|
|
|
size_t iRemainingLength = pRequest->uContentLength;
|
2003-02-28 18:37:43 +00:00
|
|
|
char *pszBuffer = malloc(pRequest->uContentLength);
|
|
|
|
char *pszData = pszBuffer;
|
2002-12-11 21:58:13 +00:00
|
|
|
|
2005-12-19 11:05:35 +00:00
|
|
|
while (iRemainingLength>0)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
ap_soft_timeout("reading GSWeb request",
|
|
|
|
p_pRequestRec);
|
|
|
|
iReadLength=ap_get_client_block(p_pRequestRec,
|
|
|
|
pszData,
|
|
|
|
iRemainingLength);
|
2000-01-22 12:49:49 +00:00
|
|
|
ap_kill_timeout(p_pRequestRec);
|
2005-12-19 10:11:35 +00:00
|
|
|
if (iReadLength>0)
|
|
|
|
{
|
|
|
|
pszData += iReadLength;
|
|
|
|
iRemainingLength-=iReadLength;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-12-19 11:05:35 +00:00
|
|
|
/* FIXME: I think we should do some better
|
2005-12-19 10:11:35 +00:00
|
|
|
error handling but we need this so that
|
|
|
|
we don't endup backtracking the entire
|
|
|
|
content upon error which will make the
|
|
|
|
server look like it's in an endless loop.
|
|
|
|
I'm not sure whether ap_get_client_block
|
|
|
|
can ever legally return 0 eventhough
|
|
|
|
iRemainingLength was larger that 0, but
|
|
|
|
in such a case this will also get us out
|
|
|
|
of a potential endless loop. */
|
|
|
|
memset(pszData,0,iRemainingLength);
|
|
|
|
iRemainingLength=0;
|
|
|
|
}
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
2006-12-19 22:41:28 +00:00
|
|
|
GSWLog(__FILE__, __LINE__,GSW_INFO,pLogServerData,"pszBuffer(%p)=%.*s",
|
2003-02-28 18:37:43 +00:00
|
|
|
(void *)pszBuffer,
|
2002-12-11 21:58:13 +00:00
|
|
|
(int)pRequest->uContentLength,
|
|
|
|
pszBuffer);
|
|
|
|
pRequest->pContent = pszBuffer;
|
|
|
|
}
|
|
|
|
else if (pRequest->eMethod==ERequestMethod_Get)
|
|
|
|
{
|
|
|
|
// Get the QueryString
|
2003-02-28 18:37:43 +00:00
|
|
|
stURLComponents.stQueryString.pszStart =
|
|
|
|
p_pRequestRec->args;
|
|
|
|
stURLComponents.stQueryString.iLength =
|
|
|
|
p_pRequestRec->args ? strlen(p_pRequestRec->args) : 0;
|
2002-12-11 21:58:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// get the document root
|
|
|
|
/* if (pConfig && pConfig->pszRoot)
|
|
|
|
pszDocRoot = pConfig->pszRoot;
|
|
|
|
else*/
|
2003-02-28 18:37:43 +00:00
|
|
|
pszDocRoot=(char *)ap_document_root(p_pRequestRec);
|
2002-12-11 21:58:13 +00:00
|
|
|
|
2003-02-28 18:37:43 +00:00
|
|
|
// Build the response
|
|
|
|
// (Beware: tr_handleRequest free pRequest)
|
2002-12-11 21:58:13 +00:00
|
|
|
ap_soft_timeout("Call GSWeb Application",p_pRequestRec);
|
|
|
|
pRequest->pServerHandle = p_pRequestRec;
|
|
|
|
pResponse=GSWAppRequest_HandleRequest(&pRequest,
|
2003-06-25 14:43:50 +00:00
|
|
|
&stURLComponents,
|
|
|
|
p_pRequestRec->protocol,
|
|
|
|
pszDocRoot,
|
|
|
|
g_szGSWeb_StatusResponseAppName, //AppTest name
|
|
|
|
pLogServerData);
|
2002-12-11 21:58:13 +00:00
|
|
|
ap_kill_timeout(p_pRequestRec);
|
|
|
|
|
|
|
|
// Send the response (if any)
|
|
|
|
if (pResponse)
|
|
|
|
{
|
|
|
|
sendResponse(p_pRequestRec,pResponse);
|
|
|
|
GSWHTTPResponse_Free(pResponse,pLogServerData);
|
|
|
|
iRetVal = OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
iRetVal = DECLINED;
|
2003-06-25 14:43:50 +00:00
|
|
|
if (applicationName)
|
|
|
|
free(applicationName);
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
2002-12-11 21:58:13 +00:00
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
2004-12-27 16:33:24 +00:00
|
|
|
stStats._endHandleRequestTS=GSWTime_now();
|
|
|
|
GSWStats_logStats(&stStats,pLogServerData);
|
|
|
|
GSWStats_freeVars(&stStats);
|
2002-12-11 21:58:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
iRetVal = DECLINED;
|
2004-12-27 16:33:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
GSWDebugLog(pLogServerData,"Stop GSWeb_Handler");
|
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
return iRetVal;
|
2000-03-16 16:16:49 +00:00
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// Module definitions
|
|
|
|
|
|
|
|
|
2002-12-11 21:58:13 +00:00
|
|
|
static command_rec GSWeb_Commands[] =
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWEB_CONF__ALIAS, // Command keyword
|
|
|
|
GSWeb_SetScriptAlias, // Function
|
|
|
|
NULL, // Fixed Arg
|
|
|
|
RSRC_CONF, // Type
|
|
|
|
TAKE1, // Args Descr
|
|
|
|
"ScriptAlias for GSWeb"
|
2000-01-22 12:49:49 +00:00
|
|
|
},
|
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWEB_CONF__CONFIG_FILE_PATH, // Command keyword
|
|
|
|
GSWeb_SetConfig, // Function
|
|
|
|
NULL, // Fixed Arg
|
|
|
|
RSRC_CONF, // Type
|
|
|
|
TAKE1, // Args Descr
|
|
|
|
"Configuration File Path for GSWeb"
|
2000-01-22 12:49:49 +00:00
|
|
|
},
|
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
NULL
|
2000-01-22 12:49:49 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2002-12-11 21:58:13 +00:00
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
handler_rec GSWeb_Handlers[] =
|
|
|
|
{
|
|
|
|
{ GSWEB__MIME_TYPE, GSWeb_Handler },
|
|
|
|
{ GSWEB_HANDLER, GSWeb_Handler },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
2002-12-11 21:58:13 +00:00
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/* Finally, the list of callback routines and data structures that provide */
|
|
|
|
/* the static hooks into our module from the other parts of the server. */
|
|
|
|
/* */
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
/*
|
|
|
|
* Module definition for configuration. If a particular callback is not
|
|
|
|
* needed, replace its routine name below with the word NULL.
|
|
|
|
*/
|
2005-05-09 12:20:18 +00:00
|
|
|
module gsweb_module =
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
STANDARD_MODULE_STUFF,
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWeb_Init, // Init
|
|
|
|
NULL, // Create DirectoryConfig
|
|
|
|
NULL, // Merge DirectoryConfig
|
|
|
|
GSWeb_CreateServerConfig, // Create ServerConfig
|
|
|
|
NULL, // Merge ServerConfig
|
|
|
|
GSWeb_Commands, // Commands List
|
|
|
|
GSWeb_Handlers, // Handlers List
|
|
|
|
GSWeb_Translation, // Fn to Translatie Filename/URI
|
2000-01-22 12:49:49 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
2000-03-16 16:16:49 +00:00
|
|
|
|