blob: 507479a17a40de3c8aa3ae22d4ac108d90607a9e [file] [log] [blame]
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>redirect</title><link rel="stylesheet" type="text/css" href="rivet.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Apache Rivet"><link rel="up" href="commands.html" title="Rivet Tcl Commands and Variables"><link rel="prev" href="raw_post.html" title="raw_post"><link rel="next" href="read_file.html" title="read_file"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">redirect</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="raw_post.html"><img src="images/prev.png" alt="Prev"></a> </td><th width="60%" align="center">Rivet Tcl Commands and Variables</th><td width="20%" align="right"> <a accesskey="n" href="read_file.html"><img src="images/next.png" alt="Next"></a></td></tr></table></div><div class="refentry"><div class="refentry.separator"><hr></div><a name="redirect"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>redirect — Interrupt processing and divert to a new URL</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis" style="width:80%"><div style="border: 1px solid #282; margin:1ex ; padding:.4ex; padding-left: 0.8ex; word-spacing:1ex "><span style="font-weight:bold ; font-family:monospace">::rivet::redirect</span> ?<span style="font-family:monospace; font-weight: bold;">URL</span>? ?<span style="font-family:monospace; font-weight: bold;">permanent (default: 0)</span>?</div></div></div><div class="refsect1"><a name="idp57243040"></a><h2>Description</h2><p style="width:90%">
<span style="font-family:monospace"><span class="command"><strong>::rivet::redirect</strong></span></span> diverts the browser to a new URL and marks
the redirection as either permanent in the browser local cache or
non permanent (default).
Calling <span style="font-family:monospace"><span class="command"><strong>::rivet::redirect</strong></span></span> causes the script execution to interrupt
and control passes to <span style="font-family:monospace"><span class="command"><strong>AbortScript</strong></span></span>, if such script is
set, by calling <span style="font-family:monospace"><span class="command"><strong>::rivet::abort_page</strong></span></span> and passing as abort
code a dictionary with 2 keys:
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><span style="font-family:monospace"><span class="command"><strong>error_code</strong></span></span>: string literal 'redirect'</li><li class="listitem"><span style="font-family:monospace"><span class="command"><strong>location</strong></span></span>: the URL the browser will be redirected to</li></ul></div><p style="width:90%">
</p><p style="width:90%">
<span style="font-family:monospace"><span class="command"><strong>::rivet::redirect</strong></span></span> drives the redirection by setting the
301 (permanent redirect) or 302 (non permanent redirect) HTTP status codes and
attempts to discard the output the script might have already placed in the
stdout channel buffer. Therefore the command can fail if
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">A <span style="font-family:monospace"><span class="command"><strong>flush stdout</strong></span></span> was called before <span style="font-family:monospace"><span class="command"><strong>::rivet::redirect</strong></span></span>
thus causing the HTTP headers to be sent and preventing any possibility to
manipulate them</li><li class="listitem">The channel buffer was filled causing Tcl to
flush the channel</li></ul></div><p style="width:90%">
The <span style="font-family:monospace"><span class="command"><strong>stdout</strong></span></span> channel, like any Tcl channels, can be manipulated
and if needed its internal buffer streched.
</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="raw_post.html"><img src="images/prev.png" alt="Prev"></a> </td><td width="20%" align="center"><a accesskey="u" href="commands.html"><img src="images/up.png" alt="Up"></a></td><td width="40%" align="right"> <a accesskey="n" href="read_file.html"><img src="images/next.png" alt="Next"></a></td></tr><tr><td width="40%" align="left" valign="top">raw_post </td><td width="20%" align="center"><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a></td><td width="40%" align="right" valign="top"> read_file</td></tr></table></div></body></html>