You are viewing a plain text version of this content. The canonical link for it is here.
Posted to site-cvs@tcl.apache.org by mx...@apache.org on 2014/12/18 11:24:40 UTC
svn commit: r1646430 - in /tcl/rivet/branches/2.2: ChangeLog
rivet/rivet-tcl/redirect.tcl rivet/rivet-tcl/tclIndex
src/apache-2/mod_rivet.c src/experimental/ src/rivetcmds/rivetCore.c
Author: mxmanghi
Date: Thu Dec 18 10:24:40 2014
New Revision: 1646430
URL: http://svn.apache.org/r1646430
Log:
* rivet/rivet-tcl/redirect.tcl: adding Damon's redirect command based on direct manipulation
of the headers
* src/rivetcmds/rivetCore.c: adding command [::rivet::headers sent] providing basic introspection
for the I/O buffer internal status
* src/apache-2/mod_rivet.c: moving Tcl_Flush from Rivet_ExecuteAndCheck to the very end of
Rivet_SendContent, avoiding multiple calls in case ::rivet::parse is called.
* src/experimental: removing it from this branch. Threaded code will be developed in trunk for
rivet 2.3
Added:
tcl/rivet/branches/2.2/rivet/rivet-tcl/redirect.tcl
Removed:
tcl/rivet/branches/2.2/src/experimental/
Modified:
tcl/rivet/branches/2.2/ChangeLog
tcl/rivet/branches/2.2/rivet/rivet-tcl/tclIndex
tcl/rivet/branches/2.2/src/apache-2/mod_rivet.c
tcl/rivet/branches/2.2/src/rivetcmds/rivetCore.c
Modified: tcl/rivet/branches/2.2/ChangeLog
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/2.2/ChangeLog?rev=1646430&r1=1646429&r2=1646430&view=diff
==============================================================================
--- tcl/rivet/branches/2.2/ChangeLog (original)
+++ tcl/rivet/branches/2.2/ChangeLog Thu Dec 18 10:24:40 2014
@@ -1,3 +1,13 @@
+2014-12-18 Massimo Manghi <mx...@apache.org>
+ * rivet/rivet-tcl/redirect.tcl: adding Damon's redirect command based on direct manipulation
+ of the headers
+ * src/rivetcmds/rivetCore.c: adding command [::rivet::headers sent] providing basic introspection
+ for the I/O buffer internal status
+ * src/apache-2/mod_rivet.c: moving Tcl_Flush from Rivet_ExecuteAndCheck to the very end of
+ Rivet_SendContent, avoiding multiple calls in case ::rivet::parse is called.
+ * src/experimental: removing it from this branch. Threaded code will be developed in trunk for
+ rivet 2.3
+
2014-08-04 Massimo Manghi <mx...@apache.org>
* configure.ac: adding support for --with-rivet-channel switch for alternate implementations
of a Rivet Tcl channel
Added: tcl/rivet/branches/2.2/rivet/rivet-tcl/redirect.tcl
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/2.2/rivet/rivet-tcl/redirect.tcl?rev=1646430&view=auto
==============================================================================
--- tcl/rivet/branches/2.2/rivet/rivet-tcl/redirect.tcl (added)
+++ tcl/rivet/branches/2.2/rivet/rivet-tcl/redirect.tcl Thu Dec 18 10:24:40 2014
@@ -0,0 +1,34 @@
+#
+# -- ::rivet::redirect
+#
+# Redirecting to a new URL by issuing a 301 or 302 (permanent)
+# diversion to a new resource.
+#
+# Arguments:
+#
+# - url - URL to which we are redirecting the client
+# - permanent:[0 | 1] - whether redirection will be permanent (default)
+#
+#
+
+namespace eval ::rivet {
+
+ proc ::rivet::redirect {url {permanent 0}} {
+
+ if {[::rivet::headers sent]} {
+
+ return -code error \
+ -errorcode headers_already_sent \
+ -errorinfo "Impossible to redirect: headers already sent"
+ }
+
+ ::rivet::no_body ; ## donât output anything on a redirect
+ ::rivet::headers set Location $url
+ ::rivet::headers numeric [expr {$permanent ? "301" : "302"}]
+ ::rivet::abort_page ; ## stop any further processing
+
+ return -error ok
+ }
+
+}
+
Modified: tcl/rivet/branches/2.2/rivet/rivet-tcl/tclIndex
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/2.2/rivet/rivet-tcl/tclIndex?rev=1646430&r1=1646429&r2=1646430&view=diff
==============================================================================
--- tcl/rivet/branches/2.2/rivet/rivet-tcl/tclIndex (original)
+++ tcl/rivet/branches/2.2/rivet/rivet-tcl/tclIndex Thu Dec 18 10:24:40 2014
@@ -27,3 +27,4 @@ set auto_index(::rivet::parray_table) [l
set auto_index(::rivet::load_cookies) [list source [file join $dir load_cookies.tcl]]
set auto_index(::rivet::http_accept) [list source [file join $dir http_accept.tcl]]
set auto_index(::rivet::xml) [list source [file join $dir xml.tcl]]
+set auto_index(::rivet::redirect) [list source [file join $dir redirect.tcl]]
Modified: tcl/rivet/branches/2.2/src/apache-2/mod_rivet.c
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/2.2/src/apache-2/mod_rivet.c?rev=1646430&r1=1646429&r2=1646430&view=diff
==============================================================================
--- tcl/rivet/branches/2.2/src/apache-2/mod_rivet.c (original)
+++ tcl/rivet/branches/2.2/src/apache-2/mod_rivet.c Thu Dec 18 10:24:40 2014
@@ -419,8 +419,9 @@ good:
if (!globals->req->headers_set && (globals->req->charset != NULL)) {
TclWeb_SetHeaderType (apr_pstrcat(globals->req->req->pool,"text/html;",globals->req->charset,NULL),globals->req);
}
- TclWeb_PrintHeaders(globals->req);
- Tcl_Flush(*(conf->outchannel));
+
+ /* Tcl_Flush moved to the end of Rivet_SendContent */
+
Tcl_Release(interp);
return TCL_OK;
@@ -1472,8 +1473,13 @@ Rivet_SendContent(request_rec *r)
retval = OK;
sendcleanup:
- globals->req->content_sent = 0;
+ /* Everything is done and we flush the rivet channel before resetting the status */
+
+ TclWeb_PrintHeaders(globals->req);
+ Tcl_Flush(*(conf->outchannel));
+
+ globals->req->content_sent = 0;
globals->page_aborting = 0;
if (globals->abort_code != NULL)
{
Modified: tcl/rivet/branches/2.2/src/rivetcmds/rivetCore.c
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/2.2/src/rivetcmds/rivetCore.c?rev=1646430&r1=1646429&r2=1646430&view=diff
==============================================================================
--- tcl/rivet/branches/2.2/src/rivetcmds/rivetCore.c (original)
+++ tcl/rivet/branches/2.2/src/rivetcmds/rivetCore.c Thu Dec 18 10:24:40 2014
@@ -359,13 +359,23 @@ TCL_CMD_HEADER( Rivet_Headers )
Tcl_WrongNumArgs(interp, 1, objv, "option arg ?arg ...?");
return TCL_ERROR;
}
+
+ opt = Tcl_GetStringFromObj(objv[1], NULL);
+
+ /* Basic introspection returning the value of the headers_printed flag */
+
+ if (!strcmp("sent",opt))
+ {
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(globals->req->headers_printed));
+ return TCL_OK;
+ }
+
if (globals->req->headers_printed != 0)
{
Tcl_AddObjErrorInfo(interp,
"Cannot manipulate headers - already sent", -1);
return TCL_ERROR;
}
- opt = Tcl_GetStringFromObj(objv[1], NULL);
if (!strcmp("redirect", opt)) /* ### redirect ### */
{
---------------------------------------------------------------------
To unsubscribe, e-mail: site-cvs-unsubscribe@tcl.apache.org
For additional commands, e-mail: site-cvs-help@tcl.apache.org