You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rivet-dev@tcl.apache.org by mx...@apache.org on 2008/07/04 01:25:47 UTC
svn commit: r673864 - in /tcl/rivet/trunk: ChangeLog
src/apache-1/mod_rivet.c src/apache-1/mod_rivet.h src/apache-2/mod_rivet.c
Author: mxmanghi
Date: Thu Jul 3 16:25:47 2008
New Revision: 673864
URL: http://svn.apache.org/viewvc?rev=673864&view=rev
Log:
apache 1 module change to add functionalities previously
added to the apache 2 code
Modified:
tcl/rivet/trunk/ChangeLog
tcl/rivet/trunk/src/apache-1/mod_rivet.c
tcl/rivet/trunk/src/apache-1/mod_rivet.h
tcl/rivet/trunk/src/apache-2/mod_rivet.c
Modified: tcl/rivet/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/ChangeLog?rev=673864&r1=673863&r2=673864&view=diff
==============================================================================
--- tcl/rivet/trunk/ChangeLog (original)
+++ tcl/rivet/trunk/ChangeLog Thu Jul 3 16:25:47 2008
@@ -1,3 +1,9 @@
+2008-07-03 Massimo Manghi <mx...@apache.org>
+
+ * src/apache-1/mod_rivet.[c|h]: done modifications needed to replicate
+ for the apache 1 code the functionalities added to the apache 2
+ module
+
2008-07-01 Massimo Manghi <mx...@apache.org>
* src/rivet.h: added macro STRNEQU(s1,s2) which efficiently
Modified: tcl/rivet/trunk/src/apache-1/mod_rivet.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/apache-1/mod_rivet.c?rev=673864&r1=673863&r2=673864&view=diff
==============================================================================
--- tcl/rivet/trunk/src/apache-1/mod_rivet.c (original)
+++ tcl/rivet/trunk/src/apache-1/mod_rivet.c Thu Jul 3 16:25:47 2008
@@ -21,15 +21,15 @@
#endif
/* Apache includes */
-#include "httpd.h"
-#include "http_config.h"
-#include "http_request.h"
-#include "http_core.h"
-#include "http_protocol.h"
-#include "http_log.h"
-#include "http_main.h"
-#include "util_script.h"
-#include "http_conf_globals.h"
+#include <httpd.h>
+#include <http_config.h>
+#include <http_request.h>
+#include <http_core.h>
+#include <http_protocol.h>
+#include <http_log.h>
+#include <http_main.h>
+#include <util_script.h>
+#include <http_conf_globals.h>
/* Tcl includes */
#include <tcl.h>
@@ -44,6 +44,14 @@
#include "rivetParser.h"
#include "rivetChannel.h"
+/* rivet or tcl file */
+#define CTYPE_NOT_HANDLED 0
+#define RIVET_FILE 1
+#define TCL_FILE 2
+
+#define RIVET_FILE_CTYPE "application/x-httpd-rivet"
+#define TCL_FILE_CTYPE "application/x-rivet-tcl"
+
module MODULE_VAR_EXPORT rivet_module;
/* This is used *only* in the PanicProc. Otherwise, don't touch
@@ -157,12 +165,36 @@
/* Make sure to flush the output if buffer_add was the only output */
good:
+
+ if (!globals->req->headers_set && (globals->req->charset != NULL)) {
+ char* ct_header = ap_pstrcat(globals->req->req->pool,"text/html;",globals->req->charset,NULL);
+
+// fprintf(stderr,"New header: %s\n",ct_header);
+// fflush(stderr);
+ TclWeb_SetHeaderType (ct_header,globals->req);
+ }
TclWeb_PrintHeaders(globals->req);
Tcl_Flush(*(conf->outchannel));
return TCL_OK;
}
+/* Rivet_CheckType returns true if the request is for mod_rivet */
+static int
+Rivet_CheckType (request_rec *req)
+{
+ int ctype = CTYPE_NOT_HANDLED;
+
+ if ( req->content_type != NULL ) {
+ if( STRNEQU( req->content_type, RIVET_FILE_CTYPE) ) {
+ ctype = RIVET_FILE;
+ } else if( STRNEQU( req->content_type, TCL_FILE_CTYPE) ) {
+ ctype = TCL_FILE;
+ }
+ }
+ return ctype;
+}
+
/* This is a separate function so that it may be called from 'Parse' */
int
Rivet_ParseExecFile(TclWebRequest *req, char *filename, int toplevel)
@@ -253,8 +285,8 @@
}
}
- if( STREQU( req->req->content_type, "application/x-httpd-rivet")
- || !toplevel )
+// if( STREQU( req->req->content_type, "application/x-httpd-rivet") || !toplevel )
+ if (Rivet_CheckType(req->req) == RIVET_FILE || !toplevel)
{
/* toplevel == 0 means we are being called from the parse
* command, which only works on Rivet .rvt files. */
@@ -430,6 +462,7 @@
char timefmt[MAX_STRING_LEN];
int errstatus;
int retval;
+ int ctype;
Tcl_Interp *interp;
static Tcl_Obj *request_init = NULL;
@@ -439,6 +472,11 @@
rivet_server_conf *rsc = NULL;
rivet_server_conf *rdc;
+ ctype = Rivet_CheckType(r);
+ if (ctype == CTYPE_NOT_HANDLED) {
+ return DECLINED;
+ }
+
Tcl_MutexLock(&sendMutex);
/* Set the global request req to know what we are dealing with in
@@ -450,6 +488,7 @@
globals = Tcl_GetAssocData(interp, "rivet", NULL);
globals->r = r;
globals->req = (TclWebRequest *)ap_pcalloc(r->pool, sizeof(TclWebRequest));
+ globals->req->charset = NULL;
rdc = RIVET_SERVER_CONF( r->per_dir_config );
@@ -537,7 +576,7 @@
goto sendcleanup;
}
- if (r->header_only)
+ if (r->header_only && !rsc->honor_header_only_reqs)
{
TclWeb_SetHeaderType(DEFAULT_HEADER_TYPE, globals->req);
TclWeb_PrintHeaders(globals->req);
@@ -545,6 +584,34 @@
goto sendcleanup;
}
+/* checking out content_type for possible type-charset association from the conf files */
+
+ {
+ int content_type_len = strlen(r->content_type);
+
+ if (((ctype==RIVET_FILE) && (content_type_len > strlen(RIVET_FILE_CTYPE))) || \
+ ((ctype==TCL_FILE) && (content_type_len > strlen(TCL_FILE_CTYPE)))) {
+
+ char* charset;
+
+ /* we parse content_type: we are after a 'charset' parameter definition */
+
+ charset = strstr(r->content_type,"charset");
+ if (charset != NULL) {
+ char* conf_charset;
+
+ conf_charset = ap_pstrdup(r->pool,charset);
+
+ /* ther's some freedom about spaces in the AddType lines: let's strip them off */
+
+ globals->req->charset = conf_charset;
+
+// fprintf(stderr,"conf charset --> %s\n",conf_charset);
+// fflush(stderr);
+ }
+ }
+ }
+
if (Rivet_ParseExecFile(globals->req, r->filename, 1) != TCL_OK)
{
ap_log_error(APLOG_MARK, APLOG_ERR, r->server, "%s",
@@ -566,9 +633,7 @@
retval = OK;
sendcleanup:
globals->req->content_sent = 0;
-
Tcl_MutexUnlock(&sendMutex);
-
return retval;
}
@@ -976,6 +1041,7 @@
* RivetServerConf UploadMaxSize <integer>
* RivetServerConf UploadFilesToVar <yes|no>
* RivetServerConf SeparateVirtualInterps <yes|no>
+ * RivetServerConf HonorHeaderOnlyRequests <yes|no> (2008-06-20: mm)
*/
static const char *
@@ -1001,6 +1067,8 @@
Tcl_GetBoolean (NULL, val, &rsc->upload_files_to_var);
} else if( STREQU( var, "SeparateVirtualInterps" ) ) {
Tcl_GetBoolean (NULL, val, &rsc->separate_virtual_interps);
+ } else if( STREQU( var, "HonorHeaderOnlyRequests" ) ) {
+ Tcl_GetBoolean (NULL, val, &rsc->honor_header_only_reqs);
} else {
string = Rivet_SetScript( cmd->pool, rsc, var, val);
}
@@ -1173,6 +1241,7 @@
newrsc->upload_max = oldrsc->upload_max;
newrsc->upload_files_to_var = oldrsc->upload_files_to_var;
newrsc->separate_virtual_interps = oldrsc->separate_virtual_interps;
+ newrsc->honor_header_only_reqs = oldrsc->honor_header_only_reqs;
newrsc->server_name = oldrsc->server_name;
newrsc->upload_dir = oldrsc->upload_dir;
newrsc->rivet_server_vars = oldrsc->rivet_server_vars;
@@ -1212,6 +1281,7 @@
rsc->upload_max = 0;
rsc->upload_files_to_var = 0;
rsc->separate_virtual_interps = 0;
+ rsc->honor_header_only_reqs = 0;
rsc->server_name = NULL;
rsc->upload_dir = "/tmp";
rsc->objCacheList = NULL;
@@ -1315,6 +1385,7 @@
overrides->upload_max : base->upload_max;
rsc->separate_virtual_interps = base->separate_virtual_interps;
+ rsc->honor_header_only_reqs = base->honor_header_only_reqs;
/* server_name is set up later. */
Modified: tcl/rivet/trunk/src/apache-1/mod_rivet.h
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/apache-1/mod_rivet.h?rev=673864&r1=673863&r2=673864&view=diff
==============================================================================
--- tcl/rivet/trunk/src/apache-1/mod_rivet.h (original)
+++ tcl/rivet/trunk/src/apache-1/mod_rivet.h Thu Jul 3 16:25:47 2008
@@ -72,6 +72,7 @@
int upload_max;
int upload_files_to_var;
int separate_virtual_interps;
+ int honor_header_only_reqs; /* default: 0 */
char *server_name;
char *upload_dir;
table *rivet_server_vars;
Modified: tcl/rivet/trunk/src/apache-2/mod_rivet.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/apache-2/mod_rivet.c?rev=673864&r1=673863&r2=673864&view=diff
==============================================================================
--- tcl/rivet/trunk/src/apache-2/mod_rivet.c (original)
+++ tcl/rivet/trunk/src/apache-2/mod_rivet.c Thu Jul 3 16:25:47 2008
@@ -1635,8 +1635,8 @@
apr_collapse_spaces(charset,charset);
globals->req->charset = charset;
- fprintf(stderr,"%s\n",charset);
- fflush(stderr);
+// fprintf(stderr,"conf charset --> %s\n",conf_charset);
+// fflush(stderr);
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-cvs-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-cvs-help@tcl.apache.org