This is an automated email from the ASF dual-hosted git repository. mxmanghi pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tcl-rivet.git
The following commit(s) were added to refs/heads/master by this push: new 6897f46 * src/mod_rivet_ng/TclWebapache.c: removed unnecessary call to TclWeb_InitEnvVars when loading input headers 6897f46 is described below commit 6897f46e9751acbf5ed3ef5973fc214de6422a86 Author: Massimo Manghi <massimo.man...@gmail.com> AuthorDate: Wed Nov 3 16:10:00 2021 +0100 * src/mod_rivet_ng/TclWebapache.c: removed unnecessary call to TclWeb_InitEnvVars when loading input headers --- ChangeLog | 5 +++++ src/mod_rivet_ng/TclWebapache.c | 28 +++++++++++++++------------- tests/env.test | 4 ++++ tests/headers.test | 5 ++++- 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index de0035c..e8bd533 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2021-11-03 Massimo Manghi <mxman...@apache.org> + * src/mod_rivet_ng/TclWebapache.c: removed unnecessary call to TclWeb_InitEnvVars + when loading input headers + * tests/env.test: cleaning up http tokens resources + 2021-11-01 Massimo Manghi <mxman...@apache.org> * src/mod_rivet_ng/Tclwebapache.c: expanded comments to newly introduced functions diff --git a/src/mod_rivet_ng/TclWebapache.c b/src/mod_rivet_ng/TclWebapache.c index 82148a6..c5c42dd 100644 --- a/src/mod_rivet_ng/TclWebapache.c +++ b/src/mod_rivet_ng/TclWebapache.c @@ -458,12 +458,14 @@ TclWeb_VarNumber(Tcl_Obj *result, int source, TclWebRequest *req) return TCL_OK; } +/* Environment variables. Include variables handling */ + /* These 2 array must be aligned and a one-to-one correspondence preserved * The enum include_vars_idx *must* be terminated by 'invalid_env_var' * Adding a new env variable requires * + the name of the variable be listed in include_env_vars * + a new value in the enumerator include_vars_idx must be added in the - * corresponding position of the variable names array + * position corresponding of the variable names array * + the switch construct in function TclWeb_SelectEnvIncludeVar must * be expanded to handle the new case identified by the new enumerator value */ @@ -607,13 +609,9 @@ static void TclWeb_InitEnvVars (rivet_thread_private* private) { TclWebRequest *req = private->req; - apr_table_t *table; - int idx; if (ENV_IS_LOADED(req->environment_set)) return; - table = req->req->subprocess_env; - /* Retrieve cgi variables. */ if (!ENV_CGI_VARS_LOADED(req->environment_set)) { @@ -624,17 +622,20 @@ TclWeb_InitEnvVars (rivet_thread_private* private) ap_add_common_vars(req->req); } - /* Loading into 'table' the include vars */ + /* Loading into 'req->req->subprocess_env' the include vars */ - /* actually this is not necessary. ENV_VARS is modified only here therefore - * if it's set this function has been called already - * and it should have returned at the beginning of the execution. I keep - * it for clarity and uniformity with the CGI variables and in case - * the incremental environment control is extended + /* actually this check is not necessary. ENV_VARS_M is set only here therefore + * if it's set this function has been called already and it should have returned + * at the beginning of ies execution. I keep it for clarity and uniformity with the + * CGI variables and in case the incremental environment handling is extended */ if (!ENV_VARS_LOADED(req->environment_set)) { + apr_table_t *table; + int idx; + + table = req->req->subprocess_env; for (idx = 0;idx < invalid_env_var;idx++) { apr_table_set(table,include_env_vars[idx],TclWeb_SelectEnvIncludeVar(private,idx)); @@ -732,7 +733,8 @@ TclWeb_GetHeaderVars(Tcl_Obj *headersvar,rivet_thread_private* private) req = private->req; - TclWeb_InitEnvVars(private); + // I actually don't see why we need to load the whole environment here + //TclWeb_InitEnvVars(private); Tcl_IncrRefCount(headersvar); /* Transfer client request headers to TCL request namespace. */ @@ -748,7 +750,7 @@ TclWeb_GetHeaderVars(Tcl_Obj *headersvar,rivet_thread_private* private) Tcl_IncrRefCount(key); Tcl_IncrRefCount(val); - /* See comment in TclWeb_GetEnvVars concerning Bug 48963*/ + /* See comment in TclWeb_GetEnvVars concerning Bug #48963*/ Tcl_ObjSetVar2(req->interp, headersvar, key, val, 0); Tcl_DecrRefCount(key); diff --git a/tests/env.test b/tests/env.test index 155836c..182df4f 100644 --- a/tests/env.test +++ b/tests/env.test @@ -8,12 +8,14 @@ set rvttestfilename env.rvt ::tcltest::test env-1.1 {Environment variable} { set page [ ::http::geturl "${urlbase}$rvttestfilename?load_env=true" ] regexp -line "^env\\(DOCUMENT_NAME\\) = $rvttestfilename\$" [::http::data $page] match + ::http::cleanup $page set match } "env(DOCUMENT_NAME) = $rvttestfilename" ::tcltest::test env-1.2 {Environment variable} { set page [ ::http::geturl "${urlbase}$rvttestfilename?load_env=false" ] regexp -line "^env\\(DOCUMENT_NAME\\) = $rvttestfilename\$" [::http::data $page] match + ::http::cleanup $page set match } "env(DOCUMENT_NAME) = $rvttestfilename" @@ -23,6 +25,8 @@ set rvttestfilename env.rvt set page2 [ ::http::geturl "${urlbase}$rvttestfilename?protocol=1"] set match2 [string trim [::http::data $page2]] #puts "proto: $match1 $match2" + ::http::cleanup $page1 + ::http::cleanup $page2 expr [string match $match1 $match2] } "1" diff --git a/tests/headers.test b/tests/headers.test index 698ee2f..f10d369 100644 --- a/tests/headers.test +++ b/tests/headers.test @@ -1,4 +1,7 @@ -# $Id$ +# -- headers.test +# +# testing ::rivet::load_headers command +# set testfilename1 headers.rvt --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@tcl.apache.org For additional commands, e-mail: commits-h...@tcl.apache.org