2000-01-22 12:49:49 +00:00
|
|
|
/* mod_gsweb.c - GSWeb: Apache Module
|
|
|
|
Copyright (C) 1999 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
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>
|
|
|
|
|
2002-12-11 21:58:13 +00:00
|
|
|
#include "../common/config.h"
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include "GSWUtil.h"
|
|
|
|
#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
|
|
|
|
module GSWeb_Module;
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2002-12-11 21:58:13 +00:00
|
|
|
#ifdef Apache2
|
|
|
|
/*
|
|
|
|
* Declare ourselves so the configuration routines can find and know us.
|
|
|
|
* We'll fill it in at the end of the module.
|
|
|
|
*/
|
|
|
|
module AP_MODULE_DECLARE_DATA GSWeb_Module;
|
|
|
|
|
|
|
|
#include <ap_compat.h>
|
|
|
|
#include <apr_pools.h>
|
|
|
|
#include <apr_strings.h>
|
|
|
|
#include <apr_tables.h>
|
|
|
|
|
|
|
|
#define ap_soft_timeout(s, r) ;
|
|
|
|
#define ap_hard_timeout(s, r) ;
|
|
|
|
#define ap_kill_timeout(r) ;
|
|
|
|
|
|
|
|
typedef apr_pool_t pool;
|
|
|
|
typedef apr_array_header_t array_header;
|
|
|
|
typedef apr_table_t table;
|
|
|
|
typedef apr_table_entry_t table_entry;
|
|
|
|
#else
|
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
|
|
|
|
};
|
2002-12-11 21:58:13 +00:00
|
|
|
#endif
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2003-04-04 18:24:19 +00:00
|
|
|
// 1.x/2.x Compatibility
|
|
|
|
#ifdef Apache2
|
|
|
|
#define APR_PSPRINTF apr_psprintf
|
|
|
|
#else
|
|
|
|
#define APR_PSPRINTF ap_psprintf
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
&GSWeb_Module);
|
2002-12-11 21:58:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-04-04 18:24:19 +00:00
|
|
|
#ifdef Apache2
|
|
|
|
static int GSWeb_PostConfig(apr_pool_t *p, apr_pool_t *plog,
|
|
|
|
apr_pool_t *ptemp, server_rec *s)
|
|
|
|
{
|
2003-04-09 17:12:00 +00:00
|
|
|
char buffer[256]="mod_gsweb/"
|
|
|
|
GSWEB_SERVER_ADAPTOR_VERSION_MAJOR_STRING
|
|
|
|
"." GSWEB_SERVER_ADAPTOR_VERSION_MINOR_STRING
|
|
|
|
"rev";
|
|
|
|
RevisionStringToRevisionValue(buffer+strlen(buffer),moduleRevision);
|
|
|
|
ap_add_version_component(p, buffer);
|
|
|
|
return OK;
|
2003-04-04 18:24:19 +00:00
|
|
|
}
|
|
|
|
#endif
|
2000-01-22 12:49:49 +00:00
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// Init
|
2002-12-11 21:58:13 +00:00
|
|
|
#ifdef Apache2
|
2003-02-28 18:37:43 +00:00
|
|
|
static void
|
|
|
|
GSWeb_ChildInit(apr_pool_t *p,
|
|
|
|
server_rec *p_pServerRec)
|
2002-12-11 21:58:13 +00:00
|
|
|
#else
|
2003-02-28 18:37:43 +00:00
|
|
|
static void
|
|
|
|
GSWeb_Init(server_rec *p_pServerRec,
|
|
|
|
pool *p)
|
2002-12-11 21:58:13 +00:00
|
|
|
#endif
|
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);
|
2000-08-25 10:36:16 +00:00
|
|
|
GSWLog(GSW_INFO,p_pServerRec,
|
2003-02-28 18:37:43 +00:00
|
|
|
"GSWeb Init Start Config. Handler: " GSWEB_HANDLER);
|
2000-08-25 10:36:16 +00:00
|
|
|
GSWLog(GSW_DEBUG,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);
|
|
|
|
*/
|
2000-08-25 10:36:16 +00:00
|
|
|
GSWLog(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
|
|
|
|
2000-08-25 10:36:16 +00:00
|
|
|
GSWLog(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;
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWLog(GSW_DEBUG,p_pServerRec,
|
|
|
|
"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;
|
|
|
|
|
|
|
|
GSWLog(GSW_DEBUG,pServerRec,"Start GSWeb_SetDocRoot");
|
|
|
|
pConfig=(GSWeb_Config *)ap_get_module_config(pServerRec->module_config,
|
|
|
|
&GSWeb_Module);
|
|
|
|
pConfig->pszRoot = p_pszArg;
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWLog(GSW_DEBUG,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;
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWLog(GSW_DEBUG,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;
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWLog(GSW_DEBUG,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;
|
|
|
|
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWLog(GSW_DEBUG,pServerRec,"Start GSWeb_SetConfig");
|
2002-12-11 21:58:13 +00:00
|
|
|
pConfig=GSWeb_GetServerConfig(pServerRec);
|
|
|
|
GSWLog(GSW_DEBUG,pServerRec,"pConfig=%p",pConfig);
|
|
|
|
GSWLog(GSW_DEBUG,pServerRec,"p_pszArg=%s",p_pszArg);
|
2000-01-22 12:49:49 +00:00
|
|
|
pConfig->pszConfigPath = p_pszArg;
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWLog(GSW_DEBUG,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));
|
|
|
|
GSWLog(GSW_DEBUG,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
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWLog(GSW_ERROR,p_pRequestRec->server,
|
|
|
|
"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
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWLog(GSW_DEBUG,
|
|
|
|
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
|
|
|
|
{
|
|
|
|
GSWLog(GSW_DEBUG,p_pRequestRec->server,"GSWeb_Translation Declined");
|
|
|
|
iRetValue=DECLINED;
|
|
|
|
};
|
2000-08-25 10:36:16 +00:00
|
|
|
GSWLog(GSW_DEBUG,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;
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWLog(GSW_DEBUG,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
|
|
|
{
|
|
|
|
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
|
|
|
headers[i].key,headers[i].val);
|
|
|
|
#ifdef DEBUG
|
|
|
|
GSWLog(GSW_DEBUG,pServerRec,"key=%s value=%s",
|
|
|
|
headers[i].key,headers[i].val);
|
|
|
|
#endif
|
|
|
|
};
|
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,
|
|
|
|
#ifdef Apache2
|
|
|
|
ap_get_server_version()
|
|
|
|
#else
|
|
|
|
SERVER_VERSION
|
|
|
|
#endif
|
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,
|
|
|
|
APR_PSPRINTF(p_pRequestRec->pool,
|
|
|
|
"%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;
|
|
|
|
};
|
|
|
|
pszPort = APR_PSPRINTF(p_pRequestRec->pool,
|
|
|
|
"%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);
|
2002-12-11 21:58:13 +00:00
|
|
|
#ifdef Apache2
|
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,NULL));
|
2002-12-11 21:58:13 +00:00
|
|
|
#else /* Apache 1.x */
|
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
|
|
|
#endif
|
|
|
|
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);
|
2003-04-04 18:24:19 +00:00
|
|
|
pszPort = APR_PSPRINTF(p_pRequestRec->pool,
|
|
|
|
"%u",
|
2002-12-11 21:58:13 +00:00
|
|
|
#ifdef Apache2
|
2003-04-04 18:24:19 +00:00
|
|
|
pConnection->remote_addr->port
|
2002-12-11 21:58:13 +00:00
|
|
|
#else
|
2003-04-04 18:24:19 +00:00
|
|
|
ntohs(pConnection->remote_addr.sin_port)
|
2002-12-11 21:58:13 +00:00
|
|
|
#endif
|
2003-04-04 18:24:19 +00:00
|
|
|
);
|
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);
|
2002-12-11 21:58:13 +00:00
|
|
|
|
|
|
|
#ifdef Apache2
|
|
|
|
//TODO
|
|
|
|
#else
|
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);
|
|
|
|
#endif
|
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);
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWLog(GSW_DEBUG,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;
|
|
|
|
#ifdef DEBUG
|
|
|
|
GSWLog(GSW_DEBUG,pServerRec,"Start getHeader key=%s value=%s headers_out=%p",
|
|
|
|
p_pElem->pszKey,(char *)p_pElem->pValue,pRequestRec->headers_out);
|
|
|
|
#endif
|
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 ?
|
2003-04-05 15:16:56 +00:00
|
|
|
#ifdef Apache2
|
2003-03-21 14:32:57 +00:00
|
|
|
ap_set_content_type(pRequestRec, (char *)p_pElem->pValue);
|
|
|
|
#endif
|
|
|
|
}
|
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);
|
2003-03-21 14:32:57 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
GSWLog(GSW_DEBUG,pServerRec,"Stop getHeader");
|
|
|
|
#endif
|
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;
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWLog(GSW_DEBUG,pServerRec,"Start sendResponse");
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2003-04-05 15:16:56 +00:00
|
|
|
// Add Headers for processing time information
|
|
|
|
#ifdef Apache2
|
|
|
|
if (GSWConfig_AddTimeHeaders())
|
|
|
|
{
|
|
|
|
char *pszBuffer= malloc(100);
|
|
|
|
apr_time_t tnow=apr_time_now();
|
|
|
|
apr_time_t duration=apr_time_as_msec(tnow-p_pRequestRec->request_time); // ms
|
|
|
|
strcpy(pszBuffer,"gswadaptor-requestdate: ");
|
|
|
|
FormatAPRTime(pszBuffer+strlen(pszBuffer),p_pRequestRec->request_time);
|
|
|
|
GSWHTTPResponse_AddHeader(p_pHTTPResponse,
|
|
|
|
pszBuffer);
|
|
|
|
strcpy(pszBuffer,"gswadaptor-sendresponsedate: ");
|
|
|
|
FormatAPRTime(pszBuffer+strlen(pszBuffer),tnow);
|
|
|
|
GSWHTTPResponse_AddHeader(p_pHTTPResponse,
|
|
|
|
pszBuffer);
|
|
|
|
sprintf(pszBuffer,"gswadaptor-processduration: %d.%d s",
|
|
|
|
(int)(duration/1000),(int)(duration%1000));
|
|
|
|
GSWHTTPResponse_AddHeader(p_pHTTPResponse,
|
|
|
|
pszBuffer);
|
|
|
|
free(pszBuffer);
|
|
|
|
pszBuffer=NULL;
|
|
|
|
};
|
|
|
|
#endif
|
2000-01-22 12:49:49 +00:00
|
|
|
// Process Headers
|
|
|
|
GSWDict_PerformForAllElem(p_pHTTPResponse->pHeaders,getHeader,p_pRequestRec);
|
|
|
|
|
2003-03-21 14:32:57 +00:00
|
|
|
GSWLog(GSW_DEBUG,pServerRec,"status message=[%s]",p_pHTTPResponse->pszStatusMessage);
|
2003-04-04 18:24:19 +00:00
|
|
|
p_pRequestRec->status_line = APR_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;
|
2003-03-21 14:32:57 +00:00
|
|
|
GSWLog(GSW_DEBUG,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;
|
2003-04-05 15:16:56 +00:00
|
|
|
#ifdef Apache2
|
2003-03-21 14:32:57 +00:00
|
|
|
ap_set_content_type(p_pRequestRec, g_szContentType_TextHtml);
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
GSWLog(GSW_DEBUG,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...
|
|
|
|
|
|
|
|
// send Headers
|
2003-04-05 15:16:56 +00:00
|
|
|
#ifndef Apache2 // No more needed in Apache2 (?)
|
2000-01-22 12:49:49 +00:00
|
|
|
ap_send_http_header(p_pRequestRec);
|
2003-03-21 14:32:57 +00:00
|
|
|
#endif
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
// 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);
|
|
|
|
};
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWLog(GSW_DEBUG,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,
|
|
|
|
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;
|
|
|
|
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWLog(GSW_DEBUG,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;
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWLog(GSW_DEBUG,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,
|
|
|
|
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;
|
|
|
|
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWLog(GSW_DEBUG,pServerRec,"Start dieWithMessage");
|
|
|
|
GSWLog(GSW_ERROR,pServerRec,"Send Error Response: %s",p_pszMessage);
|
2003-02-28 18:37:43 +00:00
|
|
|
pResponse = GSWHTTPResponse_BuildErrorResponse(NULL,p_pszMessage,
|
|
|
|
p_pRequestRec->server);
|
2000-03-16 16:16:49 +00:00
|
|
|
iReturn=dieSendResponse(p_pRequestRec,&pResponse,p_fDecline);
|
|
|
|
GSWLog(GSW_DEBUG,pServerRec,"Stop dieWithMessage");
|
|
|
|
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;
|
2002-12-11 21:58:13 +00:00
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
memset(&stURLComponents,0,sizeof(stURLComponents));
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWLog(GSW_DEBUG,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
|
|
|
|
GSWLog(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
|
|
|
|
eError=GSWParseURL(&stURLComponents,p_pRequestRec->uri,
|
|
|
|
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);
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWLog(GSW_INFO,pLogServerData,"URL Parsing Error: %s", pszURLError);
|
|
|
|
if (eError==GSWURLError_InvalidAppName)
|
2002-12-11 21:58:13 +00:00
|
|
|
{
|
|
|
|
pResponse = GSWDumpConfigFile(&stURLComponents,
|
|
|
|
p_pRequestRec->server);
|
|
|
|
iRetVal=dieSendResponse(p_pRequestRec,&pResponse,NO);
|
|
|
|
}
|
2000-01-22 12:49:49 +00:00
|
|
|
else
|
2002-12-11 21:58:13 +00:00
|
|
|
iRetVal=dieWithMessage(p_pRequestRec,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
|
|
|
|
2003-02-28 18:37:43 +00:00
|
|
|
pRequest=GSWHTTPRequest_New(p_pRequestRec->method,NULL,
|
|
|
|
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
|
|
|
{
|
2002-12-11 21:58:13 +00:00
|
|
|
iRetVal=dieWithMessage(p_pRequestRec,pszRequestError,NO);
|
|
|
|
}
|
|
|
|
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)
|
|
|
|
applicationName=strndup(stURLComponents.stAppName.pszStart,
|
|
|
|
stURLComponents.stAppName.iLength);//We'll need to release it
|
|
|
|
|
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))
|
|
|
|
{
|
|
|
|
int iReadLength=0;
|
|
|
|
int 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
|
|
|
|
|
|
|
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);
|
2002-12-11 21:58:13 +00:00
|
|
|
pszData += iReadLength;
|
|
|
|
iRemainingLength-=iReadLength;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
2002-12-11 21:58:13 +00:00
|
|
|
GSWLog(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
|
|
|
};
|
2002-12-11 21:58:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
iRetVal = DECLINED;
|
2000-03-16 16:16:49 +00:00
|
|
|
GSWLog(GSW_DEBUG,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
|
|
|
|
|
|
|
|
2002-12-11 21:58:13 +00:00
|
|
|
|
|
|
|
#ifdef Apache2
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/* Which functions are responsible for which hooks in the server. */
|
|
|
|
/* */
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
/*
|
|
|
|
* Each function our module provides to handle a particular hook is
|
|
|
|
* specified here. The functions are registered using
|
|
|
|
* ap_hook_foo(name, predecessors, successors, position)
|
|
|
|
* where foo is the name of the hook.
|
|
|
|
*
|
|
|
|
* The args are as follows:
|
|
|
|
* name -> the name of the function to call.
|
|
|
|
* predecessors -> a list of modules whose calls to this hook must be
|
|
|
|
* invoked before this module.
|
|
|
|
* successors -> a list of modules whose calls to this hook must be
|
|
|
|
* invoked after this module.
|
|
|
|
* position -> The relative position of this module. One of
|
|
|
|
* APR_HOOK_FIRST, APR_HOOK_MIDDLE, or APR_HOOK_LAST.
|
|
|
|
* Most modules will use APR_HOOK_MIDDLE. If multiple
|
|
|
|
* modules use the same relative position, Apache will
|
|
|
|
* determine which to call first.
|
|
|
|
* If your module relies on another module to run first,
|
|
|
|
* or another module running after yours, use the
|
|
|
|
* predecessors and/or successors.
|
|
|
|
*
|
|
|
|
* The number in brackets indicates the order in which the routine is called
|
|
|
|
* during request processing. Note that not all routines are necessarily
|
|
|
|
* called (such as if a resource doesn't have access restrictions).
|
|
|
|
* The actual delivery of content to the browser [9] is not handled by
|
|
|
|
* a hook; see the handler declarations below.
|
|
|
|
*/
|
2003-02-28 18:37:43 +00:00
|
|
|
static void
|
|
|
|
GSWeb_register_hooks(apr_pool_t *p)
|
2002-12-11 21:58:13 +00:00
|
|
|
{
|
|
|
|
/* ap_hook_pre_config(GSWeb_PreConfig, NULL, NULL, APR_HOOK_MIDDLE);
|
2003-04-04 18:24:19 +00:00
|
|
|
*/
|
2002-12-11 21:58:13 +00:00
|
|
|
ap_hook_post_config(GSWeb_PostConfig, NULL, NULL, APR_HOOK_MIDDLE);
|
2003-04-04 18:24:19 +00:00
|
|
|
/*
|
2002-12-11 21:58:13 +00:00
|
|
|
ap_hook_open_logs(GSWeb_OpenLogs, NULL, NULL, APR_HOOK_MIDDLE);
|
|
|
|
*/
|
|
|
|
ap_hook_child_init(GSWeb_ChildInit, NULL, NULL, APR_HOOK_MIDDLE);
|
|
|
|
ap_hook_handler(GSWeb_Handler, NULL, NULL, APR_HOOK_MIDDLE);
|
|
|
|
/* ap_hook_quick_handler(GSWeb_QuickHandler, NULL, NULL, APR_HOOK_MIDDLE);
|
|
|
|
ap_hook_pre_connection(GSWeb_PreConnection, NULL, NULL, APR_HOOK_MIDDLE);
|
|
|
|
ap_hook_process_connection(GSWeb_ProcessConnection, NULL, NULL, APR_HOOK_MIDDLE);
|
|
|
|
// [1] post read_request handling
|
|
|
|
ap_hook_post_read_request(GSWeb_PostReadRequest, NULL, NULL,APR_HOOK_MIDDLE);
|
|
|
|
ap_hook_log_transaction(GSWeb_Logger, NULL, NULL, APR_HOOK_MIDDLE);
|
|
|
|
#if 0
|
|
|
|
ap_hook_http_method(GSWeb_HttpMethod, NULL, NULL, APR_HOOK_MIDDLE);
|
|
|
|
ap_hook_default_port(GSWeb_DefaultPort, NULL, NULL, APR_HOOK_MIDDLE);
|
|
|
|
#endif
|
|
|
|
ap_hook_translate_name(GSWeb_Translation, NULL, NULL, APR_HOOK_MIDDLE);
|
|
|
|
ap_hook_header_parser(GSWeb_header_ParserHandler, NULL, NULL, APR_HOOK_MIDDLE);
|
|
|
|
ap_hook_check_user_id(GSWeb_CheckUserId, NULL, NULL, APR_HOOK_MIDDLE);
|
|
|
|
ap_hook_fixups(GSWeb_FixerUpper, NULL, NULL, APR_HOOK_MIDDLE);
|
|
|
|
ap_hook_type_checker(GSWeb_TypeChecker, NULL, NULL, APR_HOOK_MIDDLE);
|
|
|
|
ap_hook_access_checker(GSWeb_AccessChecker, NULL, NULL, APR_HOOK_MIDDLE);
|
|
|
|
ap_hook_auth_checker(GSWeb_AuthChecker, NULL, NULL, APR_HOOK_MIDDLE);
|
|
|
|
ap_hook_insert_filter(GSWeb_InsertFilter, NULL, NULL, APR_HOOK_MIDDLE);
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/* All of the routines have been declared now. Here's the list of */
|
|
|
|
/* directives specific to our module, and information about where they */
|
|
|
|
/* may appear and how the command parser should pass them to us for */
|
|
|
|
/* processing. Note that care must be taken to ensure that there are NO */
|
|
|
|
/* collisions of directive names between modules. */
|
|
|
|
/* */
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
/*
|
|
|
|
* List of directives specific to our module.
|
|
|
|
*/
|
|
|
|
static const command_rec GSWeb_Commands[] =
|
|
|
|
{
|
2003-02-28 18:37:43 +00:00
|
|
|
AP_INIT_TAKE1
|
|
|
|
(
|
|
|
|
GSWEB_CONF__ALIAS, /* directive name */
|
|
|
|
GSWeb_SetScriptAlias, /* config action routine */
|
|
|
|
NULL, /* argument to include in call */
|
|
|
|
RSRC_CONF, /* where available */
|
|
|
|
"ScriptAlias for GSWeb" /* directive description */
|
2003-03-04 17:50:45 +00:00
|
|
|
),
|
2003-02-28 18:37:43 +00:00
|
|
|
AP_INIT_TAKE1
|
|
|
|
(
|
|
|
|
GSWEB_CONF__CONFIG_FILE_PATH, /* directive name */
|
|
|
|
GSWeb_SetConfig, /* config action routine */
|
|
|
|
NULL, /* argument to include in call */
|
|
|
|
RSRC_CONF, /* where available */
|
|
|
|
"Configuration File Path for GSWeb" /* directive description */
|
|
|
|
),
|
|
|
|
{NULL}
|
2002-12-11 21:58:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
module AP_MODULE_DECLARE_DATA GSWeb_Module =
|
|
|
|
{
|
|
|
|
STANDARD20_MODULE_STUFF,
|
|
|
|
NULL,//x_create_dir_config, /* per-directory config creator */
|
|
|
|
NULL,//x_merge_dir_config, /* dir config merger */
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWeb_CreateServerConfig, /* server config creator */
|
2002-12-11 21:58:13 +00:00
|
|
|
NULL,//x_merge_server_config, /* server config merger */
|
2003-02-28 18:37:43 +00:00
|
|
|
GSWeb_Commands, /* command table */
|
|
|
|
GSWeb_register_hooks, /* set up other request processing hooks */
|
2002-12-11 21:58:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
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.
|
|
|
|
*/
|
2000-01-22 12:49:49 +00:00
|
|
|
module GSWeb_Module =
|
|
|
|
{
|
|
|
|
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
|
|
|
|
2002-12-11 21:58:13 +00:00
|
|
|
#endif
|