<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://panoptic.com/mediawiki/aolserver/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Akhassin</id>
	<title>AOLserver Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://panoptic.com/mediawiki/aolserver/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Akhassin"/>
	<link rel="alternate" type="text/html" href="https://panoptic.com/wiki/aolserver/Special:Contributions/Akhassin"/>
	<updated>2026-04-08T00:10:24Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_ictl&amp;diff=5891</id>
		<title>Ns ictl</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_ictl&amp;diff=5891"/>
		<updated>2010-11-11T02:55:32Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Man page: http://aolserver.com/docs/tcl/ns_ictl.html&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''NAME'''&lt;br /&gt;
&lt;br /&gt;
: ns_ictl - Manipulate and introspect Tcl interpreter internals&lt;br /&gt;
&lt;br /&gt;
'''SYNOPSIS'''&lt;br /&gt;
&lt;br /&gt;
: '''ns_ictl''' ''option ?arg arg ...?''&lt;br /&gt;
&lt;br /&gt;
'''DESCRIPTION'''&lt;br /&gt;
&lt;br /&gt;
: This command provides access to the internal facilities to control and configure multi-threaded Tcl interpreters in the context of AOLserver virtual servers.  It is normally used in startup initialization scripts to define how new interpreters are initialized when created and to support cleanup and re-initalization between transactions (e.g., HTTP connections).  &lt;br /&gt;
*'''ns_ictl addmodule''' ''module''&lt;br /&gt;
: Add a module to the list of modules to be initialized at startup and returns the new list as the result. This command is not normally required as each module specified in the AOLserver modules config section for the corresponding server (e.g., ''ns/server/server1/modules'') is automatically added to the list.  To be clear, this command simply appens the ''module'' to the list, it doesn't perform any loading of modules.&lt;br /&gt;
*'''ns_ictl cancel''' ''thread''&lt;br /&gt;
: Send an asynchronous interrupt request to the specified thread, cancelling any script currently executing on any AOLserver created interpreter (note the interrupt is not virtual-server specific). This command utilizes the facilities of '''Tcl_AsyncMark''' to mark as ready a callback registered with '''Tcl_AsyncCreate'''. The callback places an &amp;quot;async cancel&amp;quot; error message in the interpreter result and returns '''TCL_ERROR''' to unwind the call stack. The underlying Tcl facility has limitations, e.g., the interrupt will only be noticed when Tcl checks via '''Tcl_AsyncReady''' calls between commands and the interrupt can be caught with a '''catch''' command. See the man page for '''Tcl_AsyncCreate''' for details.  This command will throw an error if the thread doesn't have a tcl interpreter and will otherwise return nothing whether the interpreter is actively running or not.&lt;br /&gt;
*'''ns_ictl cleanup'''&lt;br /&gt;
: This command invokes any callbacks registered during a transaction via the C-level '''Ns_TclRegisterDefer''' routine.  Unlike callbacks registered with the '''ns_ictl trace deallocate''' command or '''Ns_TclRegisterTrace''' routine, these callbacks are executed only once and there is no Tcl-level access to the underlying '''Ns_TclRegisterDefer''' routine.  Currently the only thing that uses this is the C code that releases database handles.  This command is invoked by [[ns_cleanup]] Tcl procedure.&lt;br /&gt;
*'''ns_ictl epoch'''&lt;br /&gt;
: This command returns the unique id for the current duplication script for the virtual server.  The id starts as 0 when the virtual server is created and is incremented each time a new script is saved via the '''ns_ictl save''' command.  &lt;br /&gt;
*'''ns_ictl get'''&lt;br /&gt;
: Return the current duplication script for the virtual server.  This command is useful to view the duplication script created by the initialization script at startup.  &lt;br /&gt;
*'''ns_ictl getmodules'''&lt;br /&gt;
: Return the list of modules to be initialized at startup. This list corresponds to the names of modules specified in the virtual server modules config section, e.g., ''ns/server/server1/modules'' unless additional modules are added via the '''ns_ictl addmodule''' command.  &lt;br /&gt;
*'''ns_ictl gettraces''' ''which''&lt;br /&gt;
: Return the list of traces which will be invoked at the specified time. The ''which'' argument can be one of ''create, delete, allocate, deallocate, getconn'', or ''freeconn''.  The traces are returned in the order in which they will be executed.  Script level traces are returns as strings to evaluate and C-level traces are returned with strings which specify the address of the underlying C procedure and argument.  &lt;br /&gt;
*'''ns_ictl once''' ''key script''&lt;br /&gt;
: Evaluate given script once in the virtual server. The given key is a string name which uniquely identifies the corresponding script. This command is useful in a Tcl package which includes one-time initialization routines, e.g., calls to '''ns_register_proc''' or initialization of shared variables using '''nsv_set''' (see '''EXAMPLES''' below).  &lt;br /&gt;
*'''ns_ictl oncleanup''' ''script''&lt;br /&gt;
: This command is equivalent to '''ns_ictl trace deallocate''' ''script''.  &lt;br /&gt;
*'''ns_ictl oncreate''' ''script''&lt;br /&gt;
: This command is equivalent to '''ns_ictl trace create''' ''script''.  &lt;br /&gt;
*'''ns_ictl ondelete''' ''script''&lt;br /&gt;
: This command is equivalent to '''ns_ictl trace delete''' ''script''.  &lt;br /&gt;
*'''ns_ictl oninit''' ''script''&lt;br /&gt;
: This command is equivalent to '''ns_ictl trace allocate''' ''script''.  &lt;br /&gt;
*'''ns_ictl package require''' ''?-exact? package ?version?''&lt;br /&gt;
: This command is used to require a package in the calling interpreter and, if successfully loaded, it will require the exact same version in all other interpreters for the virtual server. If version consistency is not important, you can achieve the same effect with '''ns_ictl trace allocate''' {package require ''package''}. In addition, allocate is too frequent for most packages.  Package state is retained between thread allocations in a given interpreter, so at startup, doing ns_ictl oninit {package require ''package''} should be sufficient and will also work in AOLserver 4.0.  This option can be useful, however, if you want to alter the state of already created interpreters at runtime.&lt;br /&gt;
*'''ns_ictl runtraces''' which''&lt;br /&gt;
: This command runs the requested traces. The ''which'' argument must be one of '''create''', '''delete''', '''allocate''', '''deallocate''', '''getconn''', or '''freeconn'''.  Direct calls to this command are not normally necessary as the underlying C code will invoke the callbacks at the required times.  Exceptions include calling '''ns_ictl runtraces''' or testing purposes or to mimic the normal cleanup and initialization work performed on between transactions in a long running thread (see '''EXAMPLES''' below).  &lt;br /&gt;
*'''ns_ictl save''' ''script''&lt;br /&gt;
: Save the given script as the duplication script, incrementing the virtual server epoch number.  This command is normally called by the bootstrap script after constructing the script to duplicate the procedures defined by sourcing the various module initialization script files.  It's also used by [[ns_eval]] to dynamically update the interpreter 'template'.&lt;br /&gt;
*'''ns_ictl threads'''&lt;br /&gt;
: Return a list of all threads with interpreters in this processs. The ids return are small strings which represent the underlying thread ids and can be passed to the '''ns_ictl cancel''' command to send an asynchronous cancel request.  Note that the list will include currently idle threads as long as at some point they had allocated an interpreter.&lt;br /&gt;
*'''ns_ictl trace create''' ''script''&lt;br /&gt;
: Register ''script'' to be called when an interpreter is first created. This is useful to create procedures, require packages, or initialize other state to be used during the lifetime of the interpreter.  &lt;br /&gt;
*'''ns_ictl trace delete''' ''script''&lt;br /&gt;
: Register ''script'' to be called before an interpreter is destroyed. This is useful to free any resources which may have been allocated for the interpreter during the lifetime of the interpreter.  &lt;br /&gt;
*'''ns_ictl trace allocate''' ''script''&lt;br /&gt;
: Register ''script'' to be called each time an interpreter is allocated for use by the '''Ns_TclAllocateInterp''' routine. This is useful for reinitializing resources which may be used during a single transaction in the interpreter.  &lt;br /&gt;
*'''ns_ictl trace deallocate''' ''script''&lt;br /&gt;
: Register ''script'' to be called each time an interpreter is returned after a transaction with the '''Ns_TclDeAllocateInterp''' routine. This is useful for garbage collection, i.e., freeing any resources which may be used during a single transaction in the interpreter.  &lt;br /&gt;
*'''ns_ictl trace getconn''' ''script''&lt;br /&gt;
: Register ''script'' to be called each time an interpreter is returned and associated with an HTTP connection with the '''Ns_GetConnInterp''' routine. This could be useful to define variables relative to the HTTP request.  &lt;br /&gt;
*'''ns_ictl trace freeconn''' ''script''&lt;br /&gt;
: Register ''script'' to be called each time an HTTP connection is closed. This could be used to log information about the request, e.g., timing statistics.  Note that the interpreter may still be actively evaluating a script after the connection is closed, i.e., this is not equivalent to '''ns_ictl trace deallocate''' for connection-related interpreters.  &lt;br /&gt;
*'''ns_ictl update'''&lt;br /&gt;
: This command can be used to atomically compare the epoch of the current duplication script with the epoch of the interpreter, evaluating the script and updating the epoch in the interpreter if they do not match.  This command is generally registered as a callback with '''ns_ictl trace allocate''' by the initialization code.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''INTERPRETER ALLOCATION'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: Tcl interpreter in AOLserver are available on demand with state specific to a virtual server.  These interpreters are also expected to be reused for multiple transactions (e.g., HTTP connections, scheduled procedures, socket callbacks).  &lt;br /&gt;
: To support reuse, AOLserver provides the C-level '''Ns_TclAllocateInterp''' routine to allocate an interpreter from a per-thread cache (creating and initializing a new interpreter if necessary) and the '''Ns_TclDeAllocateInterp''' routine to return an interpreter to the cache when no longer required.  All interpreters in the per-thread cache are destroyed when a thread exists.  &lt;br /&gt;
: In general, only C-level extension writers need to call the C-level API's directly; the various Tcl-level interfaces in AOLserver (e.g., '''ADP''' pages, '''ns_regiseter_proc''', '''ns_schedule_proc''', '''ns_thread''', etc.) allocate and reuse interpreters using the C-level API's automatically before invoking the cooresponding script or ADP page.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''INTERPRETER TRACES'''&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
: To ensure a consistent state of interpreters when allocated and enable cleanup and reinitialization between transactions, each virtual server maintains a list of callbacks to be invoked at various points in the lifetime of an interpreter.  These callbacks are generally installed when the server is initialized at startup and then called automatically by the '''Ns_TclAllocateInterp''' and '''Ns_TclDeAllocateInterp''' API's at the appropriate times and in consistent order.  The '''Ns_TclRegisterTrace''' routine can be used to register C-level callbacks and the '''ns_ictl trace''' command can be used to register Tcl script callbacks.  The '''ns_ictl gettraces''' command can be used to list all currently registered callbacks, both at the Tcl script and C level.  &lt;br /&gt;
: Callbacks registered via the tracing facility are invoked in a specific order depending on the type.  Initialization style callbacks including '''create''', '''allocate''', and '''getconn''' are invoked in FIFO order, with all script callbacks invoked after all C-level callbacks.  This enables extension writers to utilize the facilities of previously initialized extensions. Correspondingly, cleanup style callbacks including '''freeconn''', '''deallocate''', and '''delete''' are invoked in LIFO order, with all scripts callbacks invoked before C-level callbacks. This helps avoid the possibility that a cleanup callback utilizes features of a previously cleaned up extension.  &lt;br /&gt;
: In addition, the '''ns_ictl package''' command can be used to consistently manage the loading of a Tcl package in all interpreters for a virtual server. This feature is mostly a convenience routine built above the generic trace framework with additional checks to ensure version number consistency.  Coupled with '''ns_ictl once''', the '''ns_ictl package''' command provides a clean framework to utilize Tcl packages in multi-threaded AOLserver (see '''EXAMPLES''').  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''VIRTUAL SERVER TCL INITIALIZATION'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: AOLserver also supports a Tcl initialization framework for virtual servers based on callbacks registered by loadable modules and the sourcing of scripts files located in corresponding directories. Options to '''ns_ictl''' to support this framework include ''save'', ''get'', ''epoch'', and ''update'' and are used in conjunction with the generic tracing facility by the virtual server bootstrap script (normally ''bin/init.tcl''). The '''ns_eval''' command also relies on this framework to support dynamic update of the state of interpreters.  &lt;br /&gt;
: This initialization framework pre-dates the Tcl package facilities and utilizes introspection of the state of a startup interpreter at the end of initialization to construct a single script which attempts to duplicate the state in subsequent interpreters.  Steps taken during this initialization include:  &lt;br /&gt;
*1.  Load all modules in the server's module config section, e.g.,&lt;br /&gt;
: ''ns/server/server1/modules''.  Modules with Tcl C-level extensions typically call the legacy '''Ns_TclInitInterps''' routine or the more general '''Ns_TclRegisterTrace''' routine with the ''NS_TCL_TRACE_CREATE'' flag in their module init routine to register a callback to invoke when new interpreters are created. The callback normally creates one or more new commands in the interpreter with '''Tcl_CreateObjCommand''' but may perform any per-interpreter initialization required, e.g., creating and saving private state with the '''Tcl_SetAssocData''' facility.  In addition, as modules are loaded, the string name of the module is added to the list of known modules.  &lt;br /&gt;
*2.  After all C modules are loaded, AOLserver creates a new Tcl&lt;br /&gt;
: interpreter for the virtual server, executing any trace callbacks already registered via the loaded C modules (e.g., any '''Ns_TclInitInterps''' callbacks) and then sources the virtual server bootstrap script, normally ''bin/init.tcl''.  This script creates a few utility procedures and then sources all ''private'' and ''public'' script files in directories which correspond to loaded modules in the order in which they were loaded.  These directories are normally relative to the virtual server and to the AOLserver installation directory, e.g., initialization script files for the module ''mymod'' in the ''server1'' virtual server would be searched for in the ''servers/server1/modules/tcl/mymod/'' and ''modules/tcl/mymod/''.  Any ''init.tcl'' file found in each directory is sourced first with all remaining files sourced in alphabetical order. In addition, any files in the ''public'' directory with identical names to files in the private directory are skipped as a means to enable overloading of specific functionality on a per-server basis.  In practice, most modules only contain shared utility procedures defined in the ''public'' directories and the ''private'' directories are empty or non-existant. The script files normally contain a mix of commands to evaluate once for server configuration (e.g., a call to '''ns_register_proc''' to bind a Tcl procedure to an HTTP request URL) with '''proc''' and '''namespace''' commands to provide additional functionality in the interpreter.  &lt;br /&gt;
*3.  After all script files have been sourced, the bootstrap script&lt;br /&gt;
: code then uses a collection of recursive procedures to extract the definitions of all procedures defined in all namespaces.  The definitions are used to construct a script which attempts to duplicate the state of the initialization interpreters.  This scripts is then saved as the per-virtual server duplication script with the '''ns_ictl save''' command which also increments the ''epoch'' to 1.  There are limits to this approach to determine the full state, e.g., it does not attempt to duplicate any global variables which may have been defined in the startup scripts. Typically, startup scripts will use '''nsv_set''' or other mechanisms to store such shared state.  &lt;br /&gt;
*4.  The bootstrap code then uses the '''ns_ictl trace allocate'''&lt;br /&gt;
: command to register a callback to the '''ns_ictl update''' command each time an interpreter is allocated for use.  In practice, interpreters are created with the default ''epoch'' of 0 and the first call to '''ns_ictl update''' determines an out-of-date condition, evaluates the duplication script, and increments the interpreter's ''epoch'' to 1 to match the state created by the startup interp.  &lt;br /&gt;
*5.  Subsequent calls the '''ns_eval''', if any, will evaluate the&lt;br /&gt;
: given script and then re-generate and save the duplication script as was done at startup, incrementing the ''epoch'' once again. In this way, dynamic updates which are detected in other interpreters on their next call to '''ns_ictl update''' can be supported in a limited fashion.  &lt;br /&gt;
: In practice, while generally successful, this duplication technique has inhibited the clean use of proper Tcl package extensions and encouraged the use of the '''ns_eval''' command which is generally not recommended for the non-deterministic manner in which it attempts to dynamically reconfigure a server.  Also, commands required to configure the server once (e.g., calls to '''ns_register_proc''') are inter-mixed with '''proc''' commands designed to extend functionality in all interpreters, complicating configuration management.  &lt;br /&gt;
: As an alternative, the example below illustrates a means to more explicitly manage configuration through a combination of direct calls to '''ns_ictl trace create''' and '''ns_ictl once'''. Unfortunately, the all encompassing nature of the legacy initialization approach makes it difficult to incrementally move to this cleaner approach because the duplication script construction code is unable to distinguish between state created with the newer, cleaner '''ns_ictl''' commands and state created as a side effect of one or more script files being sourced.  As such, it is expected the legacy initialization framework will remain in place until AOLserver 5.x when it will be removed entirely in a non-backwards compatible move towards the cleaner API's.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''EXAMPLES'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: This example illustrates the use of '''ns_ictl package''' and '''ns_ictl once''' to load an AOLserver-aware Tcl package into a virtual server.  The following code could be added to the virtual server bootstrap script, ''bin/init.tcl'', to load ''MyPkg'' in the virtual server:  &lt;br /&gt;
: &lt;br /&gt;
    &amp;lt;pre&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    #&lt;br /&gt;
    # Startup code in bin/init.tcl:&lt;br /&gt;
    #&lt;br /&gt;
    # Load MyPkg in all interps (including this one).&lt;br /&gt;
    #&lt;br /&gt;
    ns_ictl package require MyPkg&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;/pre&amp;gt;  &lt;br /&gt;
: This call will result in the package being loaded into the startup interpreter in the ordinary Tcl fashion (see the '''package''' man page for details).  Ordinary Tcl extension packages would need no modifications but packages which utilize AOLserver-specific features or require garbage collection between transactions could also use '''ns_ictl''' for finer grained control. For example, the ''init.tcl'' script specified by the '''package ifneeded''' command in the ''MyPkg'' package's ''pkgIndex.tcl'' file could contains:  &lt;br /&gt;
: &lt;br /&gt;
    &amp;lt;pre&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    #&lt;br /&gt;
    # Package code in lib/myPkg1.0/init.tcl:&lt;br /&gt;
    #&lt;br /&gt;
    #&lt;br /&gt;
    &lt;br /&gt;
    package provide MyPkg 1.0&lt;br /&gt;
    &lt;br /&gt;
    #&lt;br /&gt;
    # Server init which will be executed the first time called,&lt;br /&gt;
    # normally in the context of the startup interpreter as above.&lt;br /&gt;
    #&lt;br /&gt;
    &lt;br /&gt;
    ns_ictl once MyPkg {&lt;br /&gt;
        # Register the run Tcl proc HTTP handler.&lt;br /&gt;
        ns_register_proc /mypkg mkpkg::run&lt;br /&gt;
        # Register a garbage collection callback.&lt;br /&gt;
        ns_ictl trace deallocate mypkg::cleanup&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    #&lt;br /&gt;
    # Code which will be invoked to initialize the package in&lt;br /&gt;
    # all interpreters when required.&lt;br /&gt;
    #&lt;br /&gt;
    proc mypkg::run {} {&lt;br /&gt;
        ... handle /mypkg requests ...&lt;br /&gt;
    }&lt;br /&gt;
    proc mkpkg::cleanup {} {&lt;br /&gt;
        ... cleanup transaction resources for mypkg, e.g., db handles ...&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;/pre&amp;gt;  &lt;br /&gt;
: Other examples:&lt;br /&gt;
    % ns_ictl epoch&lt;br /&gt;
    1&lt;br /&gt;
&lt;br /&gt;
    % ns_ictl getmodules&lt;br /&gt;
    nsdb nslog nscp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''SEE ALSO'''&lt;br /&gt;
&lt;br /&gt;
: [[ns_cleanup]], [[ns_init]], [[ns_eval]], [[ns_markfordelete]]&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]] - [[Category:Core Tcl API]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=What%27s_new_in_4.5&amp;diff=5857</id>
		<title>What's new in 4.5</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=What%27s_new_in_4.5&amp;diff=5857"/>
		<updated>2010-07-18T18:02:05Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a fairly comprehensive list of new features and changes in AOLserver 4.5 and 4.5.1 (compared to 4.0).  If you know of anything that is missing, please add it.&lt;br /&gt;
&lt;br /&gt;
=== Connection Management: ===&lt;br /&gt;
&lt;br /&gt;
These two commands can be used together to map slow running requests to a specific pool and to set limits to avoid overload.&lt;br /&gt;
&lt;br /&gt;
* New '''[[ns_pools]]''' command to map method/URL's to specific thread pools.&lt;br /&gt;
* New '''[[ns_limits]]''' command  control the number of threads executing and/or waiting for execution by method/URL.&lt;br /&gt;
*'''Note:''' The new scheme does not pick up connection thread pool configurations from earlier versions of AOLServer. Please see the new example configuration files, and the documentation for [[ns_pools]] and [[ns_limits]], for instructions in upgrading your configuration.  &lt;br /&gt;
** As of 1 August 2007, the HEAD revision contains &amp;quot;pools.tcl&amp;quot;, which will handle many pre-4.5 configurations.&lt;br /&gt;
** There are known issues when using this feature in conjunction with virtual servers; see the SourceForge bug list (and development mailing list archive) for details.&lt;br /&gt;
** Also see [http://aolserver.am.net/docs/tuning.adpx AOLserver Tuning Configuration Parameters] for a complete list of key tuning configuration parameter changes from 4.0 to 4.5&lt;br /&gt;
&lt;br /&gt;
=== I/O Features: ===&lt;br /&gt;
&lt;br /&gt;
* New '''Ns_QueueWait''' API to enable event-driven callbacks in the driver thread before dispatching to pools for processing.&lt;br /&gt;
&lt;br /&gt;
:The allows drivers to augment data received from the client (headers, request, content) with additional data fetched over the network (likely stored in the new Ns_Cls &amp;quot;connection local storage&amp;quot; API's) before dispatching to the connection threads.  An example would be to add certain personalization data received via a web service. The rationale here is that I/O events are cheap so do those upfront instead of having expensive connection threads burdened with wasteful blocking I/O.  This is a somewhat obscure and technical interface.&lt;br /&gt;
&lt;br /&gt;
* Added ability to manage larger file uploads by spooling to a temporary file (currenty not for Windows).&lt;br /&gt;
&lt;br /&gt;
* New '''[[nsproxy]]''' module which provides the '''ns_proxy''' command which enables sending Tcl scripts to a proxy process connected via a pipe. The proxy includes core Tcl commands as well as AOLserver commands from the libnsd library. Evaluating scripts in a proxy process can be used to isolate and/or timeout thread-unsafe or otherwise unsafe 3rd party code.  Currently this module does not compile under Windows.&lt;br /&gt;
&lt;br /&gt;
=== ADP Improvements: ===&lt;br /&gt;
&lt;br /&gt;
* Added a new execution caching technique at the '''[[ns_adp_include]]''' level which allows you to save the results of execution of an included ADP and includes below that for reuse on subsequent connections up to a specified time.&lt;br /&gt;
* Added '''singlescript''' config option which turns ADP pages into a single script enabling syntax such as &amp;quot;&amp;lt;% foreach e $list { %&amp;gt; element &amp;lt;%= $e %&amp;gt; here &amp;lt;% } %&amp;gt;&amp;quot;.&lt;br /&gt;
* Added support for nested adp tags, i.e. you can now do  &amp;lt;% ns_adp_puts [ns_adp_eval {&amp;lt;% ... %&amp;gt;}] %&amp;gt; or use &amp;lt;% %&amp;gt; script within the body of a fancy tag.  Note that there is a known issue in that only a single inner instance of an adp tag is supported - see [http://sourceforge.net/tracker/?func=detail&amp;amp;aid=2958550&amp;amp;group_id=3152&amp;amp;atid=103152 Bug #2958550].&lt;br /&gt;
* Introduced a better command name to clear long-standing confusion between the previous registertag commands: '''[[ns_adp_registerscript]]''' instead of ns_register_adptag.&lt;br /&gt;
* Added '''[[ns_adp_registerproc]]''' which is similar to ns_adp_registerscript but the procedure receives individual arguments instead of an ns_set.&lt;br /&gt;
* Added output buffer improvements via new Ns_ConnFlush.  See '''[[ns_adp_close]]''' and '''[[ns_adp_flush]]'''&lt;br /&gt;
* Added automatic UTF-8 to output charset encoding.&lt;br /&gt;
* Added gzip output compression.  KNOWN ISSUE: When streaming is enabled or when the content exceeds the buffer size (see [[ns_adp_ctl]]) and is therefore flushed to the browser in multiple pieces, gzip compression is not performed even if you enable it.  However, the last piece to be flushed ends up compressed and is therefore seen as garbage by the browser.  This issue is fixed in version 4.5.2.  You can workaround by explicitly disabling gzip compression when using streaming and for large content either also disabling gzip compression or increasing the buffer size to only have a single flush.&lt;br /&gt;
* Added streaming output in chunked-encoding format instead of the previous &amp;quot;response with no length&amp;quot; HTTP/1.0 method.&lt;br /&gt;
* Enhanced ADP error handling and reporting.&lt;br /&gt;
* Added ability to trace ADP pages.  Trace output is written to the server log.  See '''[[ns_adp_ctl]]''', which is a new command for configuring the ADP execution environment at runtime.&lt;br /&gt;
&lt;br /&gt;
=== Other Improvements: ===&lt;br /&gt;
&lt;br /&gt;
* New '''Ns_TclRegisterTrace''' API to enable callbacks at key state transition points in a much more natural way.  The [[ns_ictl]] command, which now has a second and better name that should be used going forward - '''[[ns_interp_ctl]]''', has been updated to support script-level traces.&lt;br /&gt;
* New '''Ns_Task''' API designed to replace the old Ns_SockCallback API which didn't do a very good job at managing timeouts along with I/O events.&lt;br /&gt;
* New '''[[ns_returnmoved]]''' command to return 301 http status code and redirect to a new URL.&lt;br /&gt;
* New '''[[ns_internalredirect]]''' command to restart connection processing with a new URL.&lt;br /&gt;
* 4.5.1 - Added '''ns_conn channel''' and '''ns_conn contentsentlength''' subcommands to [[ns_conn]] to allow raw communication via Tcl I/O to the remote client.&lt;br /&gt;
* New '''[[ns_cache]]''' command based on ideas from the [[nscache]] module.   This is semi-backward-compatible with the ns_cache module.  The new command does not support the nscache module's -thread functionality, nor can create virtual-server-specific caches - all caches are now serverwide.  More importantly, -timeout is no longer sliding.  For details of all the differences see '''[[ns_cache]]'''.&lt;br /&gt;
* New '''[[ns_loop_ctl]]''' command to monitor and manage ''for'', ''while'', and ''foreach'' loops.&lt;br /&gt;
* Added '''ns_ictl once''' subcommand to [[ns_ictl]] / [[ns_interp_ctl]] command to execute a script exactly once for a virtual server (i.e. at startup).&lt;br /&gt;
* Added '''ns_ictl package''' subcommand to [[ns_ictl]] / [[ns_interp_ctl]] command to handle loading of Tcl packages.&lt;br /&gt;
* Added '''ns_ictl cancel''' subcommand  to [[ns_ictl]] / [[ns_interp_ctl]] command to provide the ability to sendr async-cancel messages to any interpter listed in '''ns_ictl threads''' (another new subcommand)&lt;br /&gt;
* New '''[[ns_register_fastpath]]''' command to re-enable fastpath after a previous call to '''ns_register_proc'''.&lt;br /&gt;
* New '''[[ns_register_encoding]]''' command to enable mapping of method/URL combinations to specific charset encodings used to decode the request.&lt;br /&gt;
* 4.5.1 - New '''[[ns_register_cgi]]''' command to dynamically register a CGI executable to a url.&lt;br /&gt;
* New '''[[ns_driver]]''' command to get some stats on socket drivers.&lt;br /&gt;
* [[nszlib]] module is now integrated into the core and provides for on-the-fly gzip compression and other gzip facilities in '''[[ns_zlib]]'''&lt;br /&gt;
* -all switch added to '''[[ns_addrbyhost]]''' command.&lt;br /&gt;
* Added ability to access more AOLserver functionality from a tclsh (nsv_*, ns_thread, etc).&lt;br /&gt;
* Stack checking has returned.  In a multi-threaded application like AOLserver, stack checking is important for detecting buffer overruns and deep call trees blowing your thread stack, etc.&lt;br /&gt;
* More detailed information when logging uncaught Tcl errors.  Especially for connection threads, details of the HTTP request are logged to make diagnosing the root cause of errors easier.&lt;br /&gt;
&lt;br /&gt;
=== '''Changes in Behavior from 4.0:''' ===&lt;br /&gt;
&lt;br /&gt;
* Interpreter deallocate/cleanup process is different from 4.0 - in 4.0 global variables get unset and database handles get closed prior to running the rest of the oncleanup traces.  In 4.5, that happens last.&lt;br /&gt;
* Conn ids are no longer allocated/counted per pool per virtual server and only for queued connections - conn ids are now process-wide global for all pools and provide a counter of all requests, including those that did not get to be queued and processed.&lt;br /&gt;
* Global conn variable used to only be defined when serving a request for an adp file, now it's always defined.&lt;br /&gt;
* '''[[ns_adp_dir]]''' returns the value of [ns_info pageroot] when called outside of adp, whereas in 4.0 it returned &amp;quot;/&amp;quot; and in versions before, it threw an error.&lt;br /&gt;
* '''[[ns_adp_mimetype]]''' will work outside of adps as well now.&lt;br /&gt;
* '''[[ns_startcontent]]''' -type now requires encoding specification in addition to mime type - to workaround, use a version redefined in Tcl as described under '''[[ns_startcontent]]'''&lt;br /&gt;
* AOLserver 4.5 has a newer version of TclX Keyed List implementation which enforces certain requirements of keyed list that were never enforced before. Specifically, keylkeys will throw an error in AOLserver 4.5 if you attempt to give it a table-like list of lists that has more than 2 columns.&lt;br /&gt;
* Connection thread names no longer include the virtual server name and then the pool name - now it's just the pool name instead (thread names are visible in the server log and in /_stats). Scheduled threads don't list their virtual server name in 4.0 either.  Both these issues can be fixed as follows (this is included in the [http://aolserver.am.net/code/modules/ampools.adpx ampools] module):               &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
    ns_interp_ctl trace allocate {&lt;br /&gt;
        namespace eval ::ns {}&lt;br /&gt;
        set ::ns::thread_name [ns_thread name]&lt;br /&gt;
        ns_thread name &amp;quot;$::ns::thread_name[ns_info server]&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
    ns_interp_ctl trace deallocate {&lt;br /&gt;
        if {[info exists ::ns::thread_name]} {&lt;br /&gt;
            ns_thread name $::ns::thread_name&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
* In early versions of AOLserver 4.0, '''[[ns_tmpnam]]''' on Windows used to return names without a path (they were relative to current directory).  In later builds, Jamie Rasmussen changed it to use a temp directory using GetTempPath and GetTempFileName with a prefix which resulted in names like %TEMP%/AOL1234.tmp, where 1234 is derived from time.  In 4.5.1, [[ns_tmpnam]] uses _tempnam but without a prefix and also has no extension and names are just sequential integers with sequence apparently maintained per process, thus making them not very safe. This issue is fixed in version 4.5.2.&lt;br /&gt;
* Failure to call '''[[ns_adp_abort]]''' in an adp page after calling ns_return* will now result in a Tcl error being thrown and logged.  On the other hand, without a patch from Tom Jackson (portions of which are included in version 4.5.2), ns_adp_abort itself would throw an error.  In addition, adp flush errors (i.e. due to the client no longer being connected) now also result in Tcl errors being thrown and logged. These benign errors can be suppresed using the IgnoreFinalFlushErrors setting in version 4.5.2.  See '''[[ns_adp_ctl]]''' for more details.&lt;br /&gt;
* Also see [http://aolserver.am.net/docs/tuning.adpx AOLserver Tuning Configuration Parameters] for a complete list of key tuning configuration parameter changes from 4.0 to 4.5&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=What%27s_new_in_4.5&amp;diff=5856</id>
		<title>What's new in 4.5</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=What%27s_new_in_4.5&amp;diff=5856"/>
		<updated>2010-07-06T00:49:15Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a fairly comprehensive list of new features and changes in AOLserver 4.5 and 4.5.1 (compared to 4.0).  If you know of anything that is missing, please add it.&lt;br /&gt;
&lt;br /&gt;
=== Connection Management: ===&lt;br /&gt;
&lt;br /&gt;
These two commands can be used together to map slow running requests to a specific pool and to set limits to avoid overload.&lt;br /&gt;
&lt;br /&gt;
* New '''[[ns_pools]]''' command to map method/URL's to specific thread pools.&lt;br /&gt;
* New '''[[ns_limits]]''' command  control the number of threads executing and/or waiting for execution by method/URL.&lt;br /&gt;
*'''Note:''' The new scheme does not pick up connection thread pool configurations from earlier versions of AOLServer. Please see the new example configuration files, and the documentation for [[ns_pools]] and [[ns_limits]], for instructions in upgrading your configuration.  &lt;br /&gt;
** As of 1 August 2007, the HEAD revision contains &amp;quot;pools.tcl&amp;quot;, which will handle many pre-4.5 configurations.&lt;br /&gt;
** There are known issues when using this feature in conjunction with virtual servers; see the SourceForge bug list (and development mailing list archive) for details.&lt;br /&gt;
** Also see [http://aolserver.am.net/docs/tuning.adpx AOLserver Tuning Configuration Parameters] for a complete list of key tuning configuration parameter changes from 4.0 to 4.5&lt;br /&gt;
&lt;br /&gt;
=== I/O Features: ===&lt;br /&gt;
&lt;br /&gt;
* New '''Ns_QueueWait''' API to enable event-driven callbacks in the driver thread before dispatching to pools for processing.&lt;br /&gt;
&lt;br /&gt;
:The allows drivers to augment data received from the client (headers, request, content) with additional data fetched over the network (likely stored in the new Ns_Cls &amp;quot;connection local storage&amp;quot; API's) before dispatching to the connection threads.  An example would be to add certain personalization data received via a web service. The rationale here is that I/O events are cheap so do those upfront instead of having expensive connection threads burdened with wasteful blocking I/O.  This is a somewhat obscure and technical interface.&lt;br /&gt;
&lt;br /&gt;
* Added ability to manage larger file uploads by spooling to a temporary file (currenty not for Windows).&lt;br /&gt;
&lt;br /&gt;
* New '''[[nsproxy]]''' module which provides the '''ns_proxy''' command which enables sending Tcl scripts to a proxy process connected via a pipe. The proxy includes core Tcl commands as well as AOLserver commands from the libnsd library. Evaluating scripts in a proxy process can be used to isolate and/or timeout thread-unsafe or otherwise unsafe 3rd party code.  Currently this module does not compile under Windows.&lt;br /&gt;
&lt;br /&gt;
=== ADP Improvements: ===&lt;br /&gt;
&lt;br /&gt;
* Added a new execution caching technique at the '''[[ns_adp_include]]''' level which allows you to save the results of execution of an included ADP and includes below that for reuse on subsequent connections up to a specified time.&lt;br /&gt;
* Added '''singlescript''' config option which turns ADP pages into a single script enabling syntax such as &amp;quot;&amp;lt;% foreach e $list { %&amp;gt; element &amp;lt;%= $e %&amp;gt; here &amp;lt;% } %&amp;gt;&amp;quot;.&lt;br /&gt;
* Added support for nested adp tags, i.e. you can now do  &amp;lt;% ns_adp_puts [ns_adp_eval {&amp;lt;% ... %&amp;gt;}] %&amp;gt; or use &amp;lt;% %&amp;gt; script within the body of a fancy tag.  Note that there is a known issue in that only a single inner instance of an adp tag is supported - see [http://sourceforge.net/tracker/?func=detail&amp;amp;aid=2958550&amp;amp;group_id=3152&amp;amp;atid=103152 Bug #2958550].&lt;br /&gt;
* Introduced a better command name to clear long-standing confusion between the previous registertag commands: '''[[ns_adp_registerscript]]''' instead of ns_register_adptag.&lt;br /&gt;
* Added '''[[ns_adp_registerproc]]''' which is similar to ns_adp_registerscript but the procedure receives individual arguments instead of an ns_set.&lt;br /&gt;
* Added output buffer improvements via new Ns_ConnFlush.  See '''[[ns_adp_close]]''' and '''[[ns_adp_flush]]'''&lt;br /&gt;
* Added automatic UTF-8 to output charset encoding.&lt;br /&gt;
* Added gzip output compression.&lt;br /&gt;
* Added streaming output in chunked-encoding format instead of the previous &amp;quot;response with no length&amp;quot; HTTP/1.0 method.&lt;br /&gt;
* Enhanced ADP error handling and reporting.&lt;br /&gt;
* Added ability to trace ADP pages.  Trace output is written to the server log.  See '''[[ns_adp_ctl]]''', which is a new command for configuring the ADP execution environment at runtime.&lt;br /&gt;
&lt;br /&gt;
=== Other Improvements: ===&lt;br /&gt;
&lt;br /&gt;
* New '''Ns_TclRegisterTrace''' API to enable callbacks at key state transition points in a much more natural way.  The [[ns_ictl]] command, which now has a second and better name that should be used going forward - '''[[ns_interp_ctl]]''', has been updated to support script-level traces.&lt;br /&gt;
* New '''Ns_Task''' API designed to replace the old Ns_SockCallback API which didn't do a very good job at managing timeouts along with I/O events.&lt;br /&gt;
* New '''[[ns_returnmoved]]''' command to return 301 http status code and redirect to a new URL.&lt;br /&gt;
* New '''[[ns_internalredirect]]''' command to restart connection processing with a new URL.&lt;br /&gt;
* 4.5.1 - Added '''ns_conn channel''' and '''ns_conn contentsentlength''' subcommands to [[ns_conn]] to allow raw communication via Tcl I/O to the remote client.&lt;br /&gt;
* New '''[[ns_cache]]''' command based on ideas from the [[nscache]] module.   This is semi-backward-compatible with the ns_cache module.  The new command does not support the nscache module's -thread functionality, nor can create virtual-server-specific caches - all caches are now serverwide.  More importantly, -timeout is no longer sliding.  For details of all the differences see '''[[ns_cache]]'''.&lt;br /&gt;
* New '''[[ns_loop_ctl]]''' command to monitor and manage ''for'', ''while'', and ''foreach'' loops.&lt;br /&gt;
* Added '''ns_ictl once''' subcommand to [[ns_ictl]] / [[ns_interp_ctl]] command to execute a script exactly once for a virtual server (i.e. at startup).&lt;br /&gt;
* Added '''ns_ictl package''' subcommand to [[ns_ictl]] / [[ns_interp_ctl]] command to handle loading of Tcl packages.&lt;br /&gt;
* Added '''ns_ictl cancel''' subcommand  to [[ns_ictl]] / [[ns_interp_ctl]] command to provide the ability to sendr async-cancel messages to any interpter listed in '''ns_ictl threads''' (another new subcommand)&lt;br /&gt;
* New '''[[ns_register_fastpath]]''' command to re-enable fastpath after a previous call to '''ns_register_proc'''.&lt;br /&gt;
* New '''[[ns_register_encoding]]''' command to enable mapping of method/URL combinations to specific charset encodings used to decode the request.&lt;br /&gt;
* 4.5.1 - New '''[[ns_register_cgi]]''' command to dynamically register a CGI executable to a url.&lt;br /&gt;
* New '''[[ns_driver]]''' command to get some stats on socket drivers.&lt;br /&gt;
* [[nszlib]] module is now integrated into the core and provides for on-the-fly gzip compression and other gzip facilities in '''[[ns_zlib]]'''&lt;br /&gt;
* -all switch added to '''[[ns_addrbyhost]]''' command.&lt;br /&gt;
* Added ability to access more AOLserver functionality from a tclsh (nsv_*, ns_thread, etc).&lt;br /&gt;
* Stack checking has returned.  In a multi-threaded application like AOLserver, stack checking is important for detecting buffer overruns and deep call trees blowing your thread stack, etc.&lt;br /&gt;
* More detailed information when logging uncaught Tcl errors.  Especially for connection threads, details of the HTTP request are logged to make diagnosing the root cause of errors easier.&lt;br /&gt;
&lt;br /&gt;
=== '''Changes in Behavior from 4.0:''' ===&lt;br /&gt;
&lt;br /&gt;
* Interpreter deallocate/cleanup process is different from 4.0 - in 4.0 global variables get unset and database handles get closed prior to running the rest of the oncleanup traces.  In 4.5, that happens last.&lt;br /&gt;
* Conn ids are no longer allocated/counted per pool per virtual server and only for queued connections - conn ids are now process-wide global for all pools and provide a counter of all requests, including those that did not get to be queued and processed.&lt;br /&gt;
* Global conn variable used to only be defined when serving a request for an adp file, now it's always defined.&lt;br /&gt;
* '''[[ns_adp_dir]]''' returns the value of [ns_info pageroot] when called outside of adp, whereas in 4.0 it returned &amp;quot;/&amp;quot; and in versions before, it threw an error.&lt;br /&gt;
* '''[[ns_adp_mimetype]]''' will work outside of adps as well now.&lt;br /&gt;
* '''[[ns_startcontent]]''' -type now requires encoding specification in addition to mime type - to workaround, use a version redefined in Tcl as described under '''[[ns_startcontent]]'''&lt;br /&gt;
* AOLserver 4.5 has a newer version of TclX Keyed List implementation which enforces certain requirements of keyed list that were never enforced before. Specifically, keylkeys will throw an error in AOLserver 4.5 if you attempt to give it a table-like list of lists that has more than 2 columns.&lt;br /&gt;
* Connection thread names no longer include the virtual server name and then the pool name - now it's just the pool name instead (thread names are visible in the server log and in /_stats). Scheduled threads don't list their virtual server name in 4.0 either.  Both these issues can be fixed as follows (this is included in the [http://aolserver.am.net/code/modules/ampools.adpx ampools] module):               &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
    ns_interp_ctl trace allocate {&lt;br /&gt;
        namespace eval ::ns {}&lt;br /&gt;
        set ::ns::thread_name [ns_thread name]&lt;br /&gt;
        ns_thread name &amp;quot;$::ns::thread_name[ns_info server]&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
    ns_interp_ctl trace deallocate {&lt;br /&gt;
        if {[info exists ::ns::thread_name]} {&lt;br /&gt;
            ns_thread name $::ns::thread_name&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
* In early versions of AOLserver 4.0, '''[[ns_tmpnam]]''' on Windows used to return names without a path (they were relative to current directory).  In later builds, Jamie Rasmussen changed it to use a temp directory using GetTempPath and GetTempFileName with a prefix which resulted in names like %TEMP%/AOL1234.tmp, where 1234 is derived from time.  In 4.5.1, [[ns_tmpnam]] uses _tempnam but without a prefix and also has no extension and names are just sequential integers with sequence apparently maintained per process, thus making them not very safe. This issue is fixed in version 4.5.2.&lt;br /&gt;
* Failure to call '''[[ns_adp_abort]]''' in an adp page after calling ns_return* will now result in a Tcl error being thrown and logged.  On the other hand, without a patch from Tom Jackson (portions of which are included in version 4.5.2), ns_adp_abort itself would throw an error.  In addition, adp flush errors (i.e. due to the client no longer being connected) now also result in Tcl errors being thrown and logged. These benign errors can be suppresed using the IgnoreFinalFlushErrors setting in version 4.5.2.  See '''[[ns_adp_ctl]]''' for more details.&lt;br /&gt;
* Also see [http://aolserver.am.net/docs/tuning.adpx AOLserver Tuning Configuration Parameters] for a complete list of key tuning configuration parameter changes from 4.0 to 4.5&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_filter&amp;diff=5855</id>
		<title>Ns register filter</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_filter&amp;diff=5855"/>
		<updated>2010-06-23T20:15:09Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{manpage|ns_filter}}&lt;br /&gt;
&lt;br /&gt;
'''NAME'''&lt;br /&gt;
&lt;br /&gt;
ns_register_filter - Register a filter or trace callback&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''SYNOPSIS'''&lt;br /&gt;
&lt;br /&gt;
'''ns_register_filter''' ''?-first? when method URLpatttern procname ?arg arg ...?''&lt;br /&gt;
&lt;br /&gt;
'''ns_register_filter_shortcut''' ''when method URLpatttern'' (new in AOLserver 4.5.2)&lt;br /&gt;
&lt;br /&gt;
'''ns_register_filter_error''' ''?-first? when method URLpatttern'' ([http://aolserver.am.net/code/modules/ampools.adpx ampools] module for AOLserver 4.5.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''DESCRIPTION'''&lt;br /&gt;
&lt;br /&gt;
: Registers a Tcl filter script for the specified method/URL combination on a virtual server. The script can be called at one of several times as indicated by the ''when'' argument:&lt;br /&gt;
:* '''read''' - upcoming in AOLserver 4.6 - runs in the driver thread while in the ''read'' state in a ''different'' Tcl interpreter from the rest of the connection - procedure will not receive a conn id so should not have arguments(?) and normal [[ns_conn]] and similar commands will not work.&lt;br /&gt;
:* '''prequeue''' - runs in the driver thread while in the ''ready'' state in a ''different'' Tcl interpreter from the rest of the connection - new in AOLserver 4.5 but there are known memory leak issues that are fixed in upcoming AOLserver 4.6. Procedure will not receive a conn id so should not have arguments(?) and normal [[ns_conn]] and similar commands will not work.&lt;br /&gt;
:* '''preauth''' - pre-authorization&lt;br /&gt;
:* '''postauth'''- post-authorization before page data has been returned to the user&lt;br /&gt;
:* '''write''' - upcoming in AOLserver 4.6 - Invokes proc after each write to the client.  Server normally buffers response output so this callback is called potentially just once when flushing the connection output buffers.&lt;br /&gt;
:* '''trace''' - after the connection has been processed and closed.&lt;br /&gt;
&lt;br /&gt;
: The registered script will be called at the specified stage of a connection, if the method/URL combination for the filter matches the method/URL combination for the connection using glob style (i.e. as in string match) matching. For example, these are valid ''URLpatterns'':&lt;br /&gt;
&lt;br /&gt;
    /employees/*.tcl&lt;br /&gt;
    /accounts/*/out&lt;br /&gt;
&lt;br /&gt;
: Using pre-authorization, the procedure will be called (assuming that the method/URL combination matches) just before authorization. If the procedure returns with a code of:&lt;br /&gt;
&lt;br /&gt;
:* '''TCL_OK'''  (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next pre-authorization filter for this connection, or, if there are no more pre-authorization filters, it will continue on with authorization.&lt;br /&gt;
:* '''TCL_BREAK''' (using: return &amp;quot;filter_break&amp;quot;): The server will not process any more pre-authorization filters for this connection, and it will continue on with authorization.&lt;br /&gt;
:* '''TCL_RETURN''' (using: return &amp;quot;filter_return&amp;quot;): The server will close the connection and will not run any more pre-authorization filters. It will not authorize the request, and it will not run the function registered for this METHOD/URL. It WILL run any trace functions registered for this METHOD/URL, usually including logging. It is assumed that the filter has sent a proper response (e.g., using ns_return) to the client before returning TCL_RETURN.&lt;br /&gt;
&lt;br /&gt;
: Using post-authorization, the procedure will be called (assuming that the method/URL combination matches) just after successful authorization. If the procedure returns:&lt;br /&gt;
:* '''TCL_OK''' (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next post-authorization filter for this connection, or, if there are no more post-authorization filters, it will run the function registered to handle this request.&lt;br /&gt;
:* '''TCL_BREAK''' (using: return &amp;quot;filter_break&amp;quot;): The server will not process any more post-authorization filters for this connection, and it will run the function registered to handle this request.&lt;br /&gt;
:* '''TCL_RETURN''' (using: return &amp;quot;filter_return&amp;quot;): The server will close the connection and will not run any more post-authorization filters and it will not run the function registered for this METHOD/URL. It WILL run any trace functions registered for this METHOD/URL, usually including logging. It is assumed that the filter has returned a proper response (e.g., using ns_return) to the client before returning TCL_RETURN.&lt;br /&gt;
&lt;br /&gt;
: Using trace, the procedure will be called (assuming that the method/URL combination match) after the connection has been totally processed and closed. If the procedure returns:&lt;br /&gt;
:* '''TCL_OK''' (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next trace filter.&lt;br /&gt;
:* '''TCL_BREAK''' (using: return &amp;quot;filter_break&amp;quot;): The rest of the trace filters are ignored.&lt;br /&gt;
:* '''TCL_RETURN''' (using: return &amp;quot;filter_break&amp;quot;): The rest of the trace filters are ignored.&lt;br /&gt;
&lt;br /&gt;
'''Syntax for the registered procedure:'''&lt;br /&gt;
&lt;br /&gt;
: The ''conn'' (connection id) argument is optional for procedures registered by ns_register_filter if the procedure has 1 or 2 arguments (including why but not including ''conn''). The following examples show the variations that can be used in this case:&lt;br /&gt;
&lt;br /&gt;
    '''ns_register_filter''' ''trace'' GET /noargs filter_noargs&lt;br /&gt;
    '''ns_register_filter''' ''trace'' GET /context filter_context fnord&lt;br /&gt;
    '''ns_register_filter''' ''trace'' GET /conncontext filter_conncontext&lt;br /&gt;
&lt;br /&gt;
    proc filter_noargs { why } {&lt;br /&gt;
    ns_log Notice &amp;quot;filter noargs&amp;quot;&lt;br /&gt;
    return filter_ok&lt;br /&gt;
    } ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
    proc filter_context { arg why } {&lt;br /&gt;
    ns_log Notice &amp;quot;filter context. Arg: $arg&amp;quot;&lt;br /&gt;
    return filter_ok&lt;br /&gt;
    } ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
    proc filter_conncontext { conn arg why } {&lt;br /&gt;
    ns_log Notice &amp;quot;filter conn context&amp;quot;&lt;br /&gt;
    return filter_ok&lt;br /&gt;
    } ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
: '''Note that documentation in the past listed these syntax forms as supported but they will NOT work:'''&lt;br /&gt;
    &amp;lt;code&amp;gt;&lt;br /&gt;
    #''' this will throw an error '''&lt;br /&gt;
    '''ns_register_filter''' ''postauth'' GET /threeargs threeargs aaa&lt;br /&gt;
    '''ns_register_filter''' ''postauth'' GET /fourargs fourargs aaa bbb ccc&lt;br /&gt;
    &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    # ''' these call signatures are NOT supported:'''  &lt;br /&gt;
    proc threeargs { conn context { greeble bork } why } {&lt;br /&gt;
    ...&lt;br /&gt;
    } ;&lt;br /&gt;
    proc fourargs { conn context { greeble bork } {hoover quark} why } {&lt;br /&gt;
    ...&lt;br /&gt;
    } ;&lt;br /&gt;
&lt;br /&gt;
:  '''Note that the server detects the number of arguments in your procedure only the first time it is invoked as a filter/trace.  Therefore if you change the number of arguments after this, this change will not be recognized until after a server restart.'''&lt;br /&gt;
&lt;br /&gt;
=== '''ns_register_filter_shortcut''' ===&lt;br /&gt;
: Registers a C filter at the specified ''when'' at the top of the filters list which simply returns '''NS_FILTER_RETURN''', effectively preventing further filter processing for that ''when''.  This is most useful to prevent a Tcl interpreter from being allocated to run globally registered filters for Fastpath (static) resources that don't really need that filter.  In combination with [[ns_pools]], this allows you to keep threads dedicated to serving requests for URLs registered to a particular pool lightweight, without the memory overhead of a Tcl interpreter.&lt;br /&gt;
&lt;br /&gt;
=== '''ns_register_filter_error''' ===&lt;br /&gt;
: Similarly, registers a C filter at the specified ''when'' (but not at the top, unless ''-first'' is specified) which simply returns '''NS_ERROR'''.  This is most useful with the '''trace''' ''when'' to prevent void traces (registered with [[ns_register_trace]]) and ServerTraces, i.e. access logging.&lt;br /&gt;
&lt;br /&gt;
'''NOTES'''&lt;br /&gt;
&lt;br /&gt;
: Note '''ns_register_filter''' (and _trace) is similar to '''[[ns_register_proc]]''' except that the pattern-matching for the URL is performed differently. With '''ns_register_proc''', the specified URL is used to match that URL and any URL below it in the hierarchy. Wildcards such as &amp;quot;*&amp;quot; are meaningful only for the final part of the URL, such as /scripts/*.tcl. With '''ns_register_filter''', the ''URLpattern'' is used to match URLs as a string with standard string-matching characters. '''ns_register_proc''' always results in a single match to just one procedure, whereas multiple procedures registered with '''ns_register_filter''' can be matched and will be called in the order they were registered.&lt;br /&gt;
&lt;br /&gt;
: In AOLserver 4.5.2, you can use the optional ''-first'' switch to specify that the procedure should go to the top of registered filters for a particular pattern and therefore to be called first.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: To be more precise the allowed matching characters in ''URLpattern'' are determined by [http://www.tcl.tk/man/tcl8.0/TclLib/StrMatch.htm Tcl_StrMatch] which in turn is determined by [http://www.tcl.tk/man/tcl8.0/TclCmd/string.htm#M10 TCL string match].&lt;br /&gt;
&lt;br /&gt;
'''SEE ALSO'''&lt;br /&gt;
&lt;br /&gt;
: '''[[ns_register_trace]]''' - very similar to '''ns_register_filter trace''' - known internally as ''void_traces'', procedures registered by this command fire after the procedures registered by '''ns_register_filter trace''' and differ in that they only execute if a response was successfully sent to the client (i.e. not a Server Error), plus their return value is ignored.  See '''[[ns_register_trace]]''' for more details.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[[Category:Core Tcl API]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_filter&amp;diff=5854</id>
		<title>Ns register filter</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_filter&amp;diff=5854"/>
		<updated>2010-06-23T20:14:13Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{manpage|ns_filter}}&lt;br /&gt;
&lt;br /&gt;
'''NAME'''&lt;br /&gt;
&lt;br /&gt;
ns_register_filter - Register a filter or trace callback&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''SYNOPSIS'''&lt;br /&gt;
&lt;br /&gt;
'''ns_register_filter''' ''?-first? when method URLpatttern procname ?arg arg ...?''&lt;br /&gt;
&lt;br /&gt;
'''ns_register_filter_shortcut''' ''when method URLpatttern'' (new in AOLserver 4.5.2)&lt;br /&gt;
&lt;br /&gt;
'''ns_register_filter_error''' ''?-first? when method URLpatttern'' ([http://aolserver.am.net/code/modules/ampools.adpx ampools] module for AOLserver 4.5.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''DESCRIPTION'''&lt;br /&gt;
&lt;br /&gt;
: Registers a Tcl filter script for the specified method/URL combination on a virtual server. The script can be called at one of several times as indicated by the ''when'' argument:&lt;br /&gt;
:* '''read''' - upcoming in AOLserver 4.6 - runs in the driver thread while in the ''read'' state in a ''different'' Tcl interpreter from the rest of the connection - procedure will not receive a conn id so should not have arguments(?) and normal [[ns_conn]] and similar commands will not work.&lt;br /&gt;
:* '''prequeue''' - runs in the driver thread while in the ''ready'' state in a ''different'' Tcl interpreter from the rest of the connection - new in AOLserver 4.5 but there are known memory leak issues that are fixed in upcoming AOLserver 4.6. Procedure will not receive a conn id so should not have arguments(?) and normal [[ns_conn]] and similar commands will not work.&lt;br /&gt;
:* '''preauth''' - pre-authorization&lt;br /&gt;
:* '''postauth'''- post-authorization before page data has been returned to the user&lt;br /&gt;
:* '''write''' - upcoming in AOLserver 4.6 - Invokes proc after each write to the client.  Server normally buffers response output so this callback is called potentially just once when flushing the connection output buffers.&lt;br /&gt;
:* '''trace''' - after the connection has been processed and closed.&lt;br /&gt;
&lt;br /&gt;
: The registered script will be called at the specified stage of a connection, if the method/URL combination for the filter matches the method/URL combination for the connection using glob style (i.e. as in string match) matching. For example, these are valid ''URLpatterns'':&lt;br /&gt;
&lt;br /&gt;
    /employees/*.tcl&lt;br /&gt;
    /accounts/*/out&lt;br /&gt;
&lt;br /&gt;
: Using pre-authorization, the procedure will be called (assuming that the method/URL combination matches) just before authorization. If the procedure returns with a code of:&lt;br /&gt;
&lt;br /&gt;
:* '''TCL_OK'''  (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next pre-authorization filter for this connection, or, if there are no more pre-authorization filters, it will continue on with authorization.&lt;br /&gt;
:* '''TCL_BREAK''' (using: return &amp;quot;filter_break&amp;quot;): The server will not process any more pre-authorization filters for this connection, and it will continue on with authorization.&lt;br /&gt;
:* '''TCL_RETURN''' (using: return &amp;quot;filter_return&amp;quot;): The server will close the connection and will not run any more pre-authorization filters. It will not authorize the request, and it will not run the function registered for this METHOD/URL. It WILL run any trace functions registered for this METHOD/URL, usually including logging. It is assumed that the filter has sent a proper response (e.g., using ns_return) to the client before returning TCL_RETURN.&lt;br /&gt;
&lt;br /&gt;
: Using post-authorization, the procedure will be called (assuming that the method/URL combination matches) just after successful authorization. If the procedure returns:&lt;br /&gt;
:* '''TCL_OK''' (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next post-authorization filter for this connection, or, if there are no more post-authorization filters, it will run the function registered to handle this request.&lt;br /&gt;
:* '''TCL_BREAK''' (using: return &amp;quot;filter_break&amp;quot;): The server will not process any more post-authorization filters for this connection, and it will run the function registered to handle this request.&lt;br /&gt;
:* '''TCL_RETURN''' (using: return &amp;quot;filter_return&amp;quot;): The server will close the connection and will not run any more post-authorization filters and it will not run the function registered for this METHOD/URL. It WILL run any trace functions registered for this METHOD/URL, usually including logging. It is assumed that the filter has returned a proper response (e.g., using ns_return) to the client before returning TCL_RETURN.&lt;br /&gt;
&lt;br /&gt;
: Using trace, the procedure will be called (assuming that the method/URL combination match) after the connection has been totally processed and closed. If the procedure returns:&lt;br /&gt;
:* '''TCL_OK''' (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next trace filter.&lt;br /&gt;
:* '''TCL_BREAK''' (using: return &amp;quot;filter_break&amp;quot;): The rest of the trace filters are ignored.&lt;br /&gt;
:* '''TCL_RETURN''' (using: return &amp;quot;filter_break&amp;quot;): The rest of the trace filters are ignored.&lt;br /&gt;
&lt;br /&gt;
'''Syntax for the registered procedure:'''&lt;br /&gt;
&lt;br /&gt;
: The ''conn'' (connection id) argument is optional for procedures registered by ns_register_filter if the procedure has 1 or 2 arguments (including why but not including ''conn''). The following examples show the variations that can be used in this case:&lt;br /&gt;
&lt;br /&gt;
    '''ns_register_filter''' ''trace'' GET /noargs filter_noargs&lt;br /&gt;
    '''ns_register_filter''' ''trace'' GET /context filter_context fnord&lt;br /&gt;
    '''ns_register_filter''' ''trace'' GET /conncontext filter_conncontext&lt;br /&gt;
&lt;br /&gt;
    proc filter_noargs { why } {&lt;br /&gt;
    ns_log Notice &amp;quot;filter noargs&amp;quot;&lt;br /&gt;
    return filter_ok&lt;br /&gt;
    } ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
    proc filter_context { arg why } {&lt;br /&gt;
    ns_log Notice &amp;quot;filter context. Arg: $arg&amp;quot;&lt;br /&gt;
    return filter_ok&lt;br /&gt;
    } ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
    proc filter_conncontext { conn arg why } {&lt;br /&gt;
    ns_log Notice &amp;quot;filter conn context&amp;quot;&lt;br /&gt;
    return filter_ok&lt;br /&gt;
    } ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
: '''Note that documentation in the past listed these syntax forms as supported but they will NOT work:'''&lt;br /&gt;
    &amp;lt;code&amp;gt;&lt;br /&gt;
    #''' this will throw an error '''&lt;br /&gt;
    '''ns_register_filter''' ''postauth'' GET /threeargs threeargs aaa&lt;br /&gt;
    '''ns_register_filter''' ''postauth'' GET /fourargs fourargs aaa bbb ccc&lt;br /&gt;
    &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    # ''' these call signatures are NOT supported:'''  &lt;br /&gt;
    proc threeargs { conn context { greeble bork } why } {&lt;br /&gt;
    ...&lt;br /&gt;
    } ;&lt;br /&gt;
    proc fourargs { conn context { greeble bork } {hoover quark} why } {&lt;br /&gt;
    ...&lt;br /&gt;
    } ;&lt;br /&gt;
&lt;br /&gt;
: When a GET of /threeargs is requested, the conn and why arguments will be filled automatically, the context argument will be assigned &amp;quot;aaa&amp;quot; and the greeble argument will be assigned the default value &amp;quot;bork&amp;quot;. When a GET of /fourargs is requested, the conn and why arguments will be filled automatically, the context argument will be assigned &amp;quot;aaa&amp;quot;, the greeble argument will be assigned &amp;quot;bbb&amp;quot;, and the hoover argument will be assigned the default value &amp;quot;quark&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
:  Note that the server detects the number of arguments in your procedure only the first time it is invoked as a filter/trace.  Therefore if you change the number of arguments after this, this change will not be recognized until after a server restart.&lt;br /&gt;
&lt;br /&gt;
=== '''ns_register_filter_shortcut''' ===&lt;br /&gt;
: Registers a C filter at the specified ''when'' at the top of the filters list which simply returns '''NS_FILTER_RETURN''', effectively preventing further filter processing for that ''when''.  This is most useful to prevent a Tcl interpreter from being allocated to run globally registered filters for Fastpath (static) resources that don't really need that filter.  In combination with [[ns_pools]], this allows you to keep threads dedicated to serving requests for URLs registered to a particular pool lightweight, without the memory overhead of a Tcl interpreter.&lt;br /&gt;
&lt;br /&gt;
=== '''ns_register_filter_error''' ===&lt;br /&gt;
: Similarly, registers a C filter at the specified ''when'' (but not at the top, unless ''-first'' is specified) which simply returns '''NS_ERROR'''.  This is most useful with the '''trace''' ''when'' to prevent void traces (registered with [[ns_register_trace]]) and ServerTraces, i.e. access logging.&lt;br /&gt;
&lt;br /&gt;
'''NOTES'''&lt;br /&gt;
&lt;br /&gt;
: Note '''ns_register_filter''' (and _trace) is similar to '''[[ns_register_proc]]''' except that the pattern-matching for the URL is performed differently. With '''ns_register_proc''', the specified URL is used to match that URL and any URL below it in the hierarchy. Wildcards such as &amp;quot;*&amp;quot; are meaningful only for the final part of the URL, such as /scripts/*.tcl. With '''ns_register_filter''', the ''URLpattern'' is used to match URLs as a string with standard string-matching characters. '''ns_register_proc''' always results in a single match to just one procedure, whereas multiple procedures registered with '''ns_register_filter''' can be matched and will be called in the order they were registered.&lt;br /&gt;
&lt;br /&gt;
: In AOLserver 4.5.2, you can use the optional ''-first'' switch to specify that the procedure should go to the top of registered filters for a particular pattern and therefore to be called first.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: To be more precise the allowed matching characters in ''URLpattern'' are determined by [http://www.tcl.tk/man/tcl8.0/TclLib/StrMatch.htm Tcl_StrMatch] which in turn is determined by [http://www.tcl.tk/man/tcl8.0/TclCmd/string.htm#M10 TCL string match].&lt;br /&gt;
&lt;br /&gt;
'''SEE ALSO'''&lt;br /&gt;
&lt;br /&gt;
: '''[[ns_register_trace]]''' - very similar to '''ns_register_filter trace''' - known internally as ''void_traces'', procedures registered by this command fire after the procedures registered by '''ns_register_filter trace''' and differ in that they only execute if a response was successfully sent to the client (i.e. not a Server Error), plus their return value is ignored.  See '''[[ns_register_trace]]''' for more details.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[[Category:Core Tcl API]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Tcl_API&amp;diff=5853</id>
		<title>Tcl API</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Tcl_API&amp;diff=5853"/>
		<updated>2010-06-23T20:07:37Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: /* Request processing commands */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Links to all of the Tcl commands provided by the AOLserver core &amp;quot;out of the box&amp;quot;.  To view a complete list of these commands in alphabetical order, try the [[:Category:Core Tcl API]] page.&lt;br /&gt;
&lt;br /&gt;
Like what you see here?  Want to try your hand at documenting a command, too?  Here's [[how to document the core Tcl API]].&lt;br /&gt;
&lt;br /&gt;
You can [http://aolserver.am.net/downloads/tcl-core.tip download] a syntax method tip / auto-completion file (from aolserver.am.net) for the free [http://www.activestate.com/komodo-edit Komodo Edit 5] (includes Tcl, all of ns_* APIs and some popular AOLserver modules and Tcl packages).  Place it into ''&amp;quot;%ProgramFiles%\ActiveState Komodo Edit 5\lib\support\tcl\&amp;quot;'' replacing the default Tcl-only file that comes with Komodo Edit.&lt;br /&gt;
&lt;br /&gt;
== ADP, Request and Response-oriented commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_adp_abort]], [[ns_adp_append]], [[ns_adp_argc]], [[ns_adp_argv]], [[ns_adp_bind_args]], [[ns_adp_break]], [[ns_adp_close]], [[ns_adp_ctl]], [[ns_adp_debug]], [[ns_adp_debuginit]], [[ns_adp_dir]], [[ns_adp_dump]], [[ns_adp_eval]], [[ns_adp_exception]], [[ns_adp_flush]], [[ns_adp_include]], [[ns_adp_mime]], [[ns_adp_mimetype]], [[ns_adp_parse]], [[ns_adp_puts]] ([[ns_puts]]), [[ns_adp_return]], [[ns_adp_safeeval]], [[ns_adp_stats]], [[ns_adp_stream]], [[ns_adp_tell]], [[ns_adp_trunc]]&lt;br /&gt;
&lt;br /&gt;
:'''Registered (fka fancy) ADP tags:'''&lt;br /&gt;
:[[ns_adp_registeradp]] (same as deprecated [[ns_adp_registertag]])&lt;br /&gt;
:[[ns_adp_registerproc]]&lt;br /&gt;
:[[ns_adp_registerscript]] (same as deprecated [[ns_register_adptag]]) &lt;br /&gt;
&lt;br /&gt;
:'''Request information and received content''':&lt;br /&gt;
: [[ns_conn]], [[ns_conncptofp]] (same as deprecated [[ns_writecontent]])&lt;br /&gt;
: [[ns_getform]], [[ns_getformfile]]&lt;br /&gt;
: [[ns_queryexists]], [[ns_queryget]], [[ns_querygetall]]&lt;br /&gt;
: [[ns_browsermatch]]&lt;br /&gt;
&lt;br /&gt;
:'''Standard response commands:'''&lt;br /&gt;
: [[ns_return]], [[ns_returnadminnotice]], [[ns_returnbadrequest]], [[ns_returnerror]], [[ns_returnfile]], [[ns_returnforbidden]], [[ns_returnfp]], [[ns_returnmoved]], [[ns_returnnotfound]], [[ns_returnnotice]], [[ns_returnok]], [[ns_returnredirect]], [[ns_returnunauthorized]]&lt;br /&gt;
&lt;br /&gt;
:'''More control over response:'''&lt;br /&gt;
: [[ns_setexpires]], [[ns_updateheader]], [[ns_respond]]&lt;br /&gt;
&lt;br /&gt;
:'''Manual response:'''&lt;br /&gt;
: [[ns_headers]], [[ns_startcontent]], [[ns_write]], [[ns_writefp]] / [[ns_connsendfp]] (deprecated)&lt;br /&gt;
&lt;br /&gt;
== Cache commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_cache]], [[ns_cache_flush]], [[ns_cache_keys]], [[ns_cache_names]], [[ns_cache_size]], [[ns_cache_stats]]&lt;br /&gt;
&lt;br /&gt;
== Concurrent programming commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_cond]], [[ns_critsec]], [[ns_event]], [[ns_job]], [[ns_kill]], [[ns_mutex]], [[ns_sema]], [[ns_thread]]&lt;br /&gt;
&lt;br /&gt;
== Custom data structures and variable manipulation commands ==&lt;br /&gt;
* TclX keyed lists:&lt;br /&gt;
&lt;br /&gt;
: [[keyldel]], [[keylget]], [[keylkeys]], [[keylset]]&lt;br /&gt;
* [[Thread-shared Variables]] (NSVs):&lt;br /&gt;
&lt;br /&gt;
: [[nsv_get]], [[nsv_exists]], [[nsv_set]], [[nsv_incr]], [[nsv_append]], [[nsv_lappend]], [[nsv_array]], [[nsv_unset]], [[nsv_names]]&lt;br /&gt;
* Sets and multisets:&lt;br /&gt;
&lt;br /&gt;
: [[ns_findset]], [[ns_set]]&lt;br /&gt;
* ???&lt;br /&gt;
&lt;br /&gt;
: [[ns_share]], [[ns_var]]&lt;br /&gt;
&lt;br /&gt;
== Database commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_buildsqldate]], [[ns_buildsqltime]], [[ns_buildsqltimestamp]], [[ns_db]], [[ns_dbquotename]], [[ns_dbquotevalue]], [[ns_localsqltimestamp]], [[ns_parsesqldate]], [[ns_parsesqltime]], [[ns_parsesqltimestamp]], [[ns_writecsv]]&lt;br /&gt;
&lt;br /&gt;
== DNS lookup commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_addrbyhost]], [[ns_hostbyaddr]]&lt;br /&gt;
&lt;br /&gt;
== File manipulation commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_chmod]], [[ns_cp]], [[ns_ftruncate]], [[ns_link]], [[ns_mkdir]], [[ns_mktemp]], [[ns_normalizepath]], [[ns_openexcl]], [[ns_purgefiles]], [[ns_rename]], [[ns_rmdir]], [[ns_rollfile]], [[ns_symlink]], [[ns_tmpnam]], [[ns_truncate]], [[ns_unlink]]&lt;br /&gt;
&lt;br /&gt;
== HTML manipulation commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_formvalueput]], [[ns_hrefs]], [[ns_htmlselect]], [[ns_quotehtml]], [[ns_striphtml]], [[ns_tagelement]], [[ns_tagelementset]]&lt;br /&gt;
&lt;br /&gt;
== HTTP commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_http]], [[ns_httpget]], [[ns_httpopen]], [[ns_httppost]]&lt;br /&gt;
&lt;br /&gt;
== Image manipulation commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_gifsize]], [[ns_jpegsize]]&lt;br /&gt;
&lt;br /&gt;
== Internationalization (I18N) support commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_charsets]], [[ns_choosecharset]], [[ns_cookiecharset]], [[ns_encodingforcharset]], [[ns_encodingfortype]], [[ns_formfieldcharset]], [[ns_setformencoding]] / [[ns_urlcharset]]&lt;br /&gt;
&lt;br /&gt;
== Logging commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_accesslog]], [[ns_log]], [[ns_logctl]], [[ns_logroll]]&lt;br /&gt;
&lt;br /&gt;
== Request authorization commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_checkurl]], [[ns_requestauthorize]]&lt;br /&gt;
&lt;br /&gt;
== Request processing commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_register_adp]], [[ns_register_cgi]], [[ns_register_encoding]], [[ns_register_filter_error]], [[ns_register_fastpath]], [[ns_register_filter]], [[ns_register_filter_shortcut]], [[ns_register_proc]], [[ns_register_trace]], [[ns_unregister_adp]], [[ns_unregister_proc]]&lt;br /&gt;
&lt;br /&gt;
== Scheduling commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_after]], [[ns_atclose]], [[ns_atexit]], [[ns_atshutdown]], [[ns_atsignal]], [[ns_cancel]], [[ns_pause]], [[ns_resume]], [[ns_schedule_proc]], [[ns_schedule_daily]], [[ns_schedule_weekly]], [[ns_shutdown]], [[ns_unschedule_proc]]&lt;br /&gt;
&lt;br /&gt;
== Server configuration commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_config]], [[ns_configsection]], [[ns_configsections]], [[ns_library]], [[ns_limits]], [[ns_modulepath]], [[ns_param]], [[ns_pools]], [[ns_section]]&lt;br /&gt;
&lt;br /&gt;
== Server introspection commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_driver]], [[ns_env]], [[ns_info]], [[ns_server]], [[ns_stats]] (3.x only, defunct in 4.0+)&lt;br /&gt;
&lt;br /&gt;
== Socket I/O commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_sock]], [[ns_sockaccept]], [[ns_sockblocking]], [[ns_sockcallback]], [[ns_sockcheck]], [[ns_sockclose]], [[ns_sockdup]], [[ns_sockerrno]], [[ns_socketpair]], [[ns_sockioctl]], [[ns_socklisten]], [[ns_socklistencallback]], [[ns_socknbclose]], [[ns_socknonblocking]], [[ns_socknread]], [[ns_sockopen]], [[ns_sockpair]], [[ns_sockreadwait]], [[ns_sockselect]], [[ns_socksend]], [[ns_sockstrerror]]&lt;br /&gt;
&lt;br /&gt;
== Tcl channel management commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_chan]], [[ns_cleanupchans]], [[ns_getchannels]]&lt;br /&gt;
&lt;br /&gt;
== Tcl interpreter management commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_cleanup]], [[ns_eval]], [[ns_interp_ctl]] (4.5+) / [[ns_ictl]] (4.0), [[ns_init]], [[ns_loop_ctl]], [[ns_markfordelete]], [[ns_reinit]]&lt;br /&gt;
&lt;br /&gt;
== Time commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_fmttime]], [[ns_gmtime]], [[ns_httptime]], [[ns_localtime]], [[ns_parsehttptime]], [[ns_parsetime]], [[ns_time]]&lt;br /&gt;
   &lt;br /&gt;
== Uncategorized ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_cpfp]], [[ns_crypt]], [[ns_getcsv]], [[ns_geturl]], [[ns_guesstype]], [[ns_isformcached]], [[ns_issmallint]], [[ns_paren]], [[ns_parseheader]], [[ns_parsequery]], [[ns_rand]], [[ns_resetcachedform]], [[ns_sendmail]], [[ns_sleep]], [[ns_sourceproc]], [[ns_url2file]], [[ns_urldecode]], [[ns_urlencode]], [[ns_uudecode]], [[ns_uuencode]], [[ns_zlib]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=What%27s_new_in_4.5&amp;diff=5852</id>
		<title>What's new in 4.5</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=What%27s_new_in_4.5&amp;diff=5852"/>
		<updated>2010-06-23T05:28:47Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a fairly comprehensive list of new features and changes in AOLserver 4.5 and 4.5.1 (compared to 4.0).  If you know of anything that is missing, please add it.&lt;br /&gt;
&lt;br /&gt;
=== Connection Management: ===&lt;br /&gt;
&lt;br /&gt;
These two commands can be used together to map slow running requests to a specific pool and to set limits to avoid overload.&lt;br /&gt;
&lt;br /&gt;
* New '''[[ns_pools]]''' command to map method/URL's to specific thread pools.&lt;br /&gt;
* New '''[[ns_limits]]''' command  control the number of threads executing and/or waiting for execution by method/URL.&lt;br /&gt;
*'''Note:''' The new scheme does not pick up connection thread pool configurations from earlier versions of AOLServer. Please see the new example configuration files, and the documentation for [[ns_pools]] and [[ns_limits]], for instructions in upgrading your configuration.  &lt;br /&gt;
** As of 1 August 2007, the HEAD revision contains &amp;quot;pools.tcl&amp;quot;, which will handle many pre-4.5 configurations.&lt;br /&gt;
** There are known issues when using this feature in conjunction with virtual servers; see the SourceForge bug list (and development mailing list archive) for details.&lt;br /&gt;
** Also see [http://aolserver.am.net/docs/tuning.adpx AOLserver Tuning Configuration Parameters] for a complete list of key tuning configuration parameter changes from 4.0 to 4.5&lt;br /&gt;
&lt;br /&gt;
=== I/O Features: ===&lt;br /&gt;
&lt;br /&gt;
* New '''Ns_QueueWait''' API to enable event-driven callbacks in the driver thread before dispatching to pools for processing.&lt;br /&gt;
&lt;br /&gt;
:The allows drivers to augment data received from the client (headers, request, content) with additional data fetched over the network (likely stored in the new Ns_Cls &amp;quot;connection local storage&amp;quot; API's) before dispatching to the connection threads.  An example would be to add certain personalization data received via a web service. The rationale here is that I/O events are cheap so do those upfront instead of having expensive connection threads burdened with wasteful blocking I/O.  This is a somewhat obscure and technical interface.&lt;br /&gt;
&lt;br /&gt;
* Added ability to manage larger file uploads by spooling to a temporary file (currenty not for Windows).&lt;br /&gt;
&lt;br /&gt;
* New '''[[nsproxy]]''' module which provides the '''ns_proxy''' command which enables sending Tcl scripts to a proxy process connected via a pipe. The proxy includes core Tcl commands as well as AOLserver commands from the libnsd library. Evaluating scripts in a proxy process can be used to isolate and/or timeout thread-unsafe or otherwise unsafe 3rd party code.&lt;br /&gt;
&lt;br /&gt;
=== ADP Improvements: ===&lt;br /&gt;
&lt;br /&gt;
* Added a new execution caching technique at the '''[[ns_adp_include]]''' level which allows you to save the results of execution of an included ADP and includes below that for reuse on subsequent connections up to a specified time.&lt;br /&gt;
* Added '''singlescript''' config option which turns ADP pages into a single script enabling syntax such as &amp;quot;&amp;lt;% foreach e $list { %&amp;gt; element &amp;lt;%= $e %&amp;gt; here &amp;lt;% } %&amp;gt;&amp;quot;.&lt;br /&gt;
* Added support for nested adp tags, i.e. you can now do  &amp;lt;% ns_adp_puts [ns_adp_eval {&amp;lt;% ... %&amp;gt;}] %&amp;gt; or use &amp;lt;% %&amp;gt; script within the body of a fancy tag.  Note that there is a known issue in that only a single inner instance of an adp tag is supported - see [http://sourceforge.net/tracker/?func=detail&amp;amp;aid=2958550&amp;amp;group_id=3152&amp;amp;atid=103152 Bug #2958550].&lt;br /&gt;
* Introduced a better command name to clear long-standing confusion between the previous registertag commands: '''[[ns_adp_registerscript]]''' instead of ns_register_adptag.&lt;br /&gt;
* Added '''[[ns_adp_registerproc]]''' which is similar to ns_adp_registerscript but the procedure receives individual arguments instead of an ns_set.&lt;br /&gt;
* Added output buffer improvements via new Ns_ConnFlush.  See '''[[ns_adp_close]]''' and '''[[ns_adp_flush]]'''&lt;br /&gt;
* Added automatic UTF-8 to output charset encoding.&lt;br /&gt;
* Added gzip output compression.&lt;br /&gt;
* Added streaming output in chunked-encoding format instead of the previous &amp;quot;response with no length&amp;quot; HTTP/1.0 method.&lt;br /&gt;
* Enhanced ADP error handling and reporting.&lt;br /&gt;
* Added ability to trace ADP pages.  Trace output is written to the server log.  See '''[[ns_adp_ctl]]''', which is a new command for configuring the ADP execution environment at runtime.&lt;br /&gt;
&lt;br /&gt;
=== Other Improvements: ===&lt;br /&gt;
&lt;br /&gt;
* New '''Ns_TclRegisterTrace''' API to enable callbacks at key state transition points in a much more natural way.  The [[ns_ictl]] command, which now has a second and better name that should be used going forward - '''[[ns_interp_ctl]]''', has been updated to support script-level traces.&lt;br /&gt;
* New '''Ns_Task''' API designed to replace the old Ns_SockCallback API which didn't do a very good job at managing timeouts along with I/O events.&lt;br /&gt;
* New '''[[ns_returnmoved]]''' command to return 301 http status code and redirect to a new URL.&lt;br /&gt;
* New '''[[ns_internalredirect]]''' command to restart connection processing with a new URL.&lt;br /&gt;
* 4.5.1 - Added '''ns_conn channel''' and '''ns_conn contentsentlength''' subcommands to [[ns_conn]] to allow raw communication via Tcl I/O to the remote client.&lt;br /&gt;
* New '''[[ns_cache]]''' command based on ideas from the [[nscache]] module.   This is semi-backward-compatible with the ns_cache module.  The new command does not support the nscache module's -thread functionality, nor can create virtual-server-specific caches - all caches are now serverwide.  More importantly, -timeout is no longer sliding.  For details of all the differences see '''[[ns_cache]]'''.&lt;br /&gt;
* New '''[[ns_loop_ctl]]''' command to monitor and manage ''for'', ''while'', and ''foreach'' loops.&lt;br /&gt;
* Added '''ns_ictl once''' subcommand to [[ns_ictl]] / [[ns_interp_ctl]] command to execute a script exactly once for a virtual server (i.e. at startup).&lt;br /&gt;
* Added '''ns_ictl package''' subcommand to [[ns_ictl]] / [[ns_interp_ctl]] command to handle loading of Tcl packages.&lt;br /&gt;
* Added '''ns_ictl cancel''' subcommand  to [[ns_ictl]] / [[ns_interp_ctl]] command to provide the ability to sendr async-cancel messages to any interpter listed in '''ns_ictl threads''' (another new subcommand)&lt;br /&gt;
* New '''[[ns_register_fastpath]]''' command to re-enable fastpath after a previous call to '''ns_register_proc'''.&lt;br /&gt;
* New '''[[ns_register_encoding]]''' command to enable mapping of method/URL combinations to specific charset encodings used to decode the request.&lt;br /&gt;
* 4.5.1 - New '''[[ns_register_cgi]]''' command to dynamically register a CGI executable to a url.&lt;br /&gt;
* New '''[[ns_driver]]''' command to get some stats on socket drivers.&lt;br /&gt;
* [[nszlib]] module is now integrated into the core and provides for on-the-fly gzip compression and other gzip facilities in '''[[ns_zlib]]'''&lt;br /&gt;
* -all switch added to '''[[ns_addrbyhost]]''' command.&lt;br /&gt;
* Added ability to access more AOLserver functionality from a tclsh (nsv_*, ns_thread, etc).&lt;br /&gt;
* Stack checking has returned.  In a multi-threaded application like AOLserver, stack checking is important for detecting buffer overruns and deep call trees blowing your thread stack, etc.&lt;br /&gt;
* More detailed information when logging uncaught Tcl errors.  Especially for connection threads, details of the HTTP request are logged to make diagnosing the root cause of errors easier.&lt;br /&gt;
&lt;br /&gt;
=== '''Changes in Behavior from 4.0:''' ===&lt;br /&gt;
&lt;br /&gt;
* Interpreter deallocate/cleanup process is different from 4.0 - in 4.0 global variables get unset and database handles get closed prior to running the rest of the oncleanup traces.  In 4.5, that happens last.&lt;br /&gt;
* Conn ids are no longer allocated/counted per pool per virtual server and only for queued connections - conn ids are now process-wide global for all pools and provide a counter of all requests, including those that did not get to be queued and processed.&lt;br /&gt;
* Global conn variable used to only be defined when serving a request for an adp file, now it's always defined.&lt;br /&gt;
* '''[[ns_adp_dir]]''' returns the value of [ns_info pageroot] when called outside of adp, whereas in 4.0 it returned &amp;quot;/&amp;quot; and in versions before, it threw an error.&lt;br /&gt;
* '''[[ns_adp_mimetype]]''' will work outside of adps as well now.&lt;br /&gt;
* '''[[ns_startcontent]]''' -type now requires encoding specification in addition to mime type - to workaround, use a version redefined in Tcl as described under '''[[ns_startcontent]]'''&lt;br /&gt;
* AOLserver 4.5 has a newer version of TclX Keyed List implementation which enforces certain requirements of keyed list that were never enforced before. Specifically, keylkeys will throw an error in AOLserver 4.5 if you attempt to give it a table-like list of lists that has more than 2 columns.&lt;br /&gt;
* Connection thread names no longer include the virtual server name and then the pool name - now it's just the pool name instead (thread names are visible in the server log and in /_stats). Scheduled threads don't list their virtual server name in 4.0 either.  Both these issues can be fixed as follows (this is included in the [http://aolserver.am.net/code/modules/ampools.adpx ampools] module):               &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
    ns_interp_ctl trace allocate {&lt;br /&gt;
        namespace eval ::ns {}&lt;br /&gt;
        set ::ns::thread_name [ns_thread name]&lt;br /&gt;
        ns_thread name &amp;quot;$::ns::thread_name[ns_info server]&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
    ns_interp_ctl trace deallocate {&lt;br /&gt;
        if {[info exists ::ns::thread_name]} {&lt;br /&gt;
            ns_thread name $::ns::thread_name&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
* In early versions of AOLserver 4.0, '''[[ns_tmpnam]]''' on Windows used to return names without a path (they were relative to current directory).  In later builds, Jamie Rasmussen changed it to use a temp directory using GetTempPath and GetTempFileName with a prefix which resulted in names like %TEMP%/AOL1234.tmp, where 1234 is derived from time.  In 4.5.1, [[ns_tmpnam]] uses _tempnam but without a prefix and also has no extension and names are just sequential integers with sequence apparently maintained per process, thus making them not very safe. This issue is fixed in version 4.5.2.&lt;br /&gt;
* Failure to call '''[[ns_adp_abort]]''' in an adp page after calling ns_return* will now result in a Tcl error being thrown and logged.  On the other hand, without a patch from Tom Jackson (portions of which are included in version 4.5.2), ns_adp_abort itself would throw an error.  In addition, adp flush errors (i.e. due to the client no longer being connected) now also result in Tcl errors being thrown and logged. These benign errors can be suppresed using the IgnoreFinalFlushErrors setting in version 4.5.2.  See '''[[ns_adp_ctl]]''' for more details.&lt;br /&gt;
* Also see [http://aolserver.am.net/docs/tuning.adpx AOLserver Tuning Configuration Parameters] for a complete list of key tuning configuration parameter changes from 4.0 to 4.5&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=What%27s_new_in_4.5&amp;diff=5851</id>
		<title>What's new in 4.5</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=What%27s_new_in_4.5&amp;diff=5851"/>
		<updated>2010-06-23T04:27:18Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a fairly comprehensive list of new features and changes in AOLserver 4.5 and 4.5.1 (compared to 4.0).  If you know of anything that is missing, please add it.&lt;br /&gt;
&lt;br /&gt;
=== Connection Management: ===&lt;br /&gt;
&lt;br /&gt;
These two commands can be used together to map slow running requests to a specific pool and to set limits to avoid overload.&lt;br /&gt;
&lt;br /&gt;
* New '''[[ns_pools]]''' command to map method/URL's to specific thread pools.&lt;br /&gt;
* New '''[[ns_limits]]''' command  control the number of threads executing and/or waiting for execution by method/URL.&lt;br /&gt;
*'''Note:''' The new scheme does not pick up connection thread pool configurations from earlier versions of AOLServer. Please see the new example configuration files, and the documentation for [[ns_pools]] and [[ns_limits]], for instructions in upgrading your configuration.  &lt;br /&gt;
** As of 1 August 2007, the HEAD revision contains &amp;quot;pools.tcl&amp;quot;, which will handle many pre-4.5 configurations.&lt;br /&gt;
** There are known issues when using this feature in conjunction with virtual servers; see the SourceForge bug list (and development mailing list archive) for details.&lt;br /&gt;
&lt;br /&gt;
=== I/O Features: ===&lt;br /&gt;
&lt;br /&gt;
* New '''Ns_QueueWait''' API to enable event-driven callbacks in the driver thread before dispatching to pools for processing.&lt;br /&gt;
&lt;br /&gt;
:The allows drivers to augment data received from the client (headers, request, content) with additional data fetched over the network (likely stored in the new Ns_Cls &amp;quot;connection local storage&amp;quot; API's) before dispatching to the connection threads.  An example would be to add certain personalization data received via a web service. The rationale here is that I/O events are cheap so do those upfront instead of having expensive connection threads burdened with wasteful blocking I/O.  This is a somewhat obscure and technical interface.&lt;br /&gt;
&lt;br /&gt;
* Added ability to manage larger file uploads by spooling to a temporary file (currenty not for Windows).&lt;br /&gt;
&lt;br /&gt;
* New '''[[nsproxy]]''' module which provides the '''ns_proxy''' command which enables sending Tcl scripts to a proxy process connected via a pipe. The proxy includes core Tcl commands as well as AOLserver commands from the libnsd library. Evaluating scripts in a proxy process can be used to isolate and/or timeout thread-unsafe or otherwise unsafe 3rd party code.&lt;br /&gt;
&lt;br /&gt;
=== ADP Improvements: ===&lt;br /&gt;
&lt;br /&gt;
* Added a new execution caching technique at the '''[[ns_adp_include]]''' level which allows you to save the results of execution of an included ADP and includes below that for reuse on subsequent connections up to a specified time.&lt;br /&gt;
* Added '''singlescript''' config option which turns ADP pages into a single script enabling syntax such as &amp;quot;&amp;lt;% foreach e $list { %&amp;gt; element &amp;lt;%= $e %&amp;gt; here &amp;lt;% } %&amp;gt;&amp;quot;.&lt;br /&gt;
* Added support for nested adp tags, i.e. you can now do  &amp;lt;% ns_adp_puts [ns_adp_eval {&amp;lt;% ... %&amp;gt;}] %&amp;gt; or use &amp;lt;% %&amp;gt; script within the body of a fancy tag.  Note that there is a known issue in that only a single inner instance of an adp tag is supported - see [http://sourceforge.net/tracker/?func=detail&amp;amp;aid=2958550&amp;amp;group_id=3152&amp;amp;atid=103152 Bug #2958550].&lt;br /&gt;
* Introduced a better command name to clear long-standing confusion between the previous registertag commands: '''[[ns_adp_registerscript]]''' instead of ns_register_adptag.&lt;br /&gt;
* Added '''[[ns_adp_registerproc]]''' which is similar to ns_adp_registerscript but the procedure receives individual arguments instead of an ns_set.&lt;br /&gt;
* Added output buffer improvements via new Ns_ConnFlush.  See '''[[ns_adp_close]]''' and '''[[ns_adp_flush]]'''&lt;br /&gt;
* Added automatic UTF-8 to output charset encoding.&lt;br /&gt;
* Added gzip output compression.&lt;br /&gt;
* Added streaming output in chunked-encoding format instead of the previous &amp;quot;response with no length&amp;quot; HTTP/1.0 method.&lt;br /&gt;
* Enhanced ADP error handling and reporting.&lt;br /&gt;
* Added ability to trace ADP pages.  Trace output is written to the server log.  See '''[[ns_adp_ctl]]''', which is a new command for configuring the ADP execution environment at runtime.&lt;br /&gt;
&lt;br /&gt;
=== Other Improvements: ===&lt;br /&gt;
&lt;br /&gt;
* New '''Ns_TclRegisterTrace''' API to enable callbacks at key state transition points in a much more natural way.  The [[ns_ictl]] command, which now has a second and better name that should be used going forward - '''[[ns_interp_ctl]]''', has been updated to support script-level traces.&lt;br /&gt;
* New '''Ns_Task''' API designed to replace the old Ns_SockCallback API which didn't do a very good job at managing timeouts along with I/O events.&lt;br /&gt;
* New '''[[ns_returnmoved]]''' command to return 301 http status code and redirect to a new URL.&lt;br /&gt;
* New '''[[ns_internalredirect]]''' command to restart connection processing with a new URL.&lt;br /&gt;
* 4.5.1 - Added '''ns_conn channel''' and '''ns_conn contentsentlength''' subcommands to [[ns_conn]] to allow raw communication via Tcl I/O to the remote client.&lt;br /&gt;
* New '''[[ns_cache]]''' command based on ideas from the [[nscache]] module.   This is semi-backward-compatible with the ns_cache module.  The new command does not support the nscache module's -thread functionality, nor can create virtual-server-specific caches - all caches are now serverwide.  More importantly, -timeout is no longer sliding.  For details of all the differences see '''[[ns_cache]]'''.&lt;br /&gt;
* New '''[[ns_loop_ctl]]''' command to monitor and manage ''for'', ''while'', and ''foreach'' loops.&lt;br /&gt;
* Added '''ns_ictl once''' subcommand to [[ns_ictl]] / [[ns_interp_ctl]] command to execute a script exactly once for a virtual server (i.e. at startup).&lt;br /&gt;
* Added '''ns_ictl package''' subcommand to [[ns_ictl]] / [[ns_interp_ctl]] command to handle loading of Tcl packages.&lt;br /&gt;
* Added '''ns_ictl cancel''' subcommand  to [[ns_ictl]] / [[ns_interp_ctl]] command to provide the ability to sendr async-cancel messages to any interpter listed in '''ns_ictl threads''' (another new subcommand)&lt;br /&gt;
* New '''[[ns_register_fastpath]]''' command to re-enable fastpath after a previous call to '''ns_register_proc'''.&lt;br /&gt;
* New '''[[ns_register_encoding]]''' command to enable mapping of method/URL combinations to specific charset encodings used to decode the request.&lt;br /&gt;
* 4.5.1 - New '''[[ns_register_cgi]]''' command to dynamically register a CGI executable to a url.&lt;br /&gt;
* New '''[[ns_driver]]''' command to get some stats on socket drivers.&lt;br /&gt;
* [[nszlib]] module is now integrated into the core and provides for on-the-fly gzip compression and other gzip facilities in '''[[ns_zlib]]'''&lt;br /&gt;
* -all switch added to '''[[ns_addrbyhost]]''' command.&lt;br /&gt;
* Added ability to access more AOLserver functionality from a tclsh (nsv_*, ns_thread, etc).&lt;br /&gt;
* Stack checking has returned.  In a multi-threaded application like AOLserver, stack checking is important for detecting buffer overruns and deep call trees blowing your thread stack, etc.&lt;br /&gt;
* More detailed information when logging uncaught Tcl errors.  Especially for connection threads, details of the HTTP request are logged to make diagnosing the root cause of errors easier.&lt;br /&gt;
&lt;br /&gt;
=== '''Changes in Behavior from 4.0:''' ===&lt;br /&gt;
&lt;br /&gt;
* Interpreter deallocate/cleanup process is different from 4.0 - in 4.0 global variables get unset and database handles get closed prior to running the rest of the oncleanup traces.  In 4.5, that happens last.&lt;br /&gt;
* Conn ids are no longer allocated/counted per pool per virtual server and only for queued connections - conn ids are now process-wide global for all pools and provide a counter of all requests, including those that did not get to be queued and processed.&lt;br /&gt;
* Global conn variable used to only be defined when serving a request for an adp file, now it's always defined.&lt;br /&gt;
* '''[[ns_adp_dir]]''' returns the value of [ns_info pageroot] when called outside of adp, whereas in 4.0 it returned &amp;quot;/&amp;quot; and in versions before, it threw an error.&lt;br /&gt;
* '''[[ns_adp_mimetype]]''' will work outside of adps as well now.&lt;br /&gt;
* '''[[ns_startcontent]]''' -type now requires encoding specification in addition to mime type - to workaround, use a version redefined in Tcl as described under '''[[ns_startcontent]]'''&lt;br /&gt;
* AOLserver 4.5 has a newer version of TclX Keyed List implementation which enforces certain requirements of keyed list that were never enforced before. Specifically, keylkeys will throw an error in AOLserver 4.5 if you attempt to give it a table-like list of lists that has more than 2 columns.&lt;br /&gt;
* Connection thread names no longer include the virtual server name and then the pool name - now it's just the pool name instead (thread names are visible in the server log and in /_stats). Scheduled threads don't list their virtual server name in 4.0 either.  Both these issues can be fixed as follows (this is included in the [http://aolserver.am.net/code/modules/ampools.adpx ampools] module):               &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
    ns_interp_ctl trace allocate {&lt;br /&gt;
        namespace eval ::ns {}&lt;br /&gt;
        set ::ns::thread_name [ns_thread name]&lt;br /&gt;
        ns_thread name &amp;quot;$::ns::thread_name[ns_info server]&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
    ns_interp_ctl trace deallocate {&lt;br /&gt;
        if {[info exists ::ns::thread_name]} {&lt;br /&gt;
            ns_thread name $::ns::thread_name&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
* In early versions of AOLserver 4.0, '''[[ns_tmpnam]]''' on Windows used to return names without a path (they were relative to current directory).  In later builds, Jamie Rasmussen changed it to use a temp directory using GetTempPath and GetTempFileName with a prefix which resulted in names like %TEMP%/AOL1234.tmp, where 1234 is derived from time.  In 4.5.1, [[ns_tmpnam]] uses _tempnam but without a prefix and also has no extension and names are just sequential integers with sequence apparently maintained per process, thus making them not very safe. This issue is fixed in version 4.5.2.&lt;br /&gt;
* Failure to call '''[[ns_adp_abort]]''' in an adp page after calling ns_return* will now result in a Tcl error being thrown and logged.  On the other hand, without a patch from Tom Jackson (portions of which are included in version 4.5.2), ns_adp_abort itself would throw an error.  In addition, adp flush errors (i.e. due to the client no longer being connected) now also result in Tcl errors being thrown and logged. These benign errors can be suppresed using the IgnoreFinalFlushErrors setting in version 4.5.2.  See '''[[ns_adp_ctl]]''' for more details.&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=What%27s_new_in_4.5&amp;diff=5850</id>
		<title>What's new in 4.5</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=What%27s_new_in_4.5&amp;diff=5850"/>
		<updated>2010-06-23T04:25:20Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a fairly comprehensive list of new features and changes in AOLserver 4.5 and 4.5.1 (compared to 4.0).  If you know of anything that is missing, please add it.&lt;br /&gt;
&lt;br /&gt;
=== Connection Management: ===&lt;br /&gt;
&lt;br /&gt;
These two commands can be used together to map slow running requests to a specific pool and to set limits to avoid overload.&lt;br /&gt;
&lt;br /&gt;
* New '''[[ns_pools]]''' command to map method/URL's to specific thread pools.&lt;br /&gt;
* New '''[[ns_limits]]''' command  control the number of threads executing and/or waiting for execution by method/URL.&lt;br /&gt;
*'''Note:''' The new scheme does not pick up connection thread pool configurations from earlier versions of AOLServer. Please see the new example configuration files, and the documentation for [[ns_pools]] and [[ns_limits]], for instructions in upgrading your configuration.  &lt;br /&gt;
** As of 1 August 2007, the HEAD revision contains &amp;quot;pools.tcl&amp;quot;, which will handle many pre-4.5 configurations.&lt;br /&gt;
** There are known issues when using this feature in conjunction with virtual servers; see the SourceForge bug list (and development mailing list archive) for details.&lt;br /&gt;
&lt;br /&gt;
=== I/O Features: ===&lt;br /&gt;
&lt;br /&gt;
* New '''Ns_QueueWait''' API to enable event-driven callbacks in the driver thread before dispatching to pools for processing.&lt;br /&gt;
&lt;br /&gt;
:The allows drivers to augment data received from the client (headers, request, content) with additional data fetched over the network (likely stored in the new Ns_Cls &amp;quot;connection local storage&amp;quot; API's) before dispatching to the connection threads.  An example would be to add certain personalization data received via a web service. The rationale here is that I/O events are cheap so do those upfront instead of having expensive connection threads burdened with wasteful blocking I/O.  This is a somewhat obscure and technical interface.&lt;br /&gt;
&lt;br /&gt;
* Added ability to manage larger file uploads by spooling to a temporary file (currenty not for Windows).&lt;br /&gt;
&lt;br /&gt;
* New '''[[nsproxy]]''' module which provides the '''ns_proxy''' command which enables sending Tcl scripts to a proxy process connected via a pipe. The proxy includes core Tcl commands as well as AOLserver commands from the libnsd library. Evaluating scripts in a proxy process can be used to isolate and/or timeout thread-unsafe or otherwise unsafe 3rd party code.&lt;br /&gt;
&lt;br /&gt;
=== ADP Improvements: ===&lt;br /&gt;
&lt;br /&gt;
* Added a new execution caching technique at the '''[[ns_adp_include]]''' level which allows you to save the results of execution of an included ADP and includes below that for reuse on subsequent connections up to a specified time.&lt;br /&gt;
* Added '''singlescript''' config option which turns ADP pages into a single script enabling syntax such as &amp;quot;&amp;lt;% foreach e $list { %&amp;gt; element &amp;lt;%= $e %&amp;gt; here &amp;lt;% } %&amp;gt;&amp;quot;.&lt;br /&gt;
* Added support for nested adp tags, i.e. you can now do  &amp;lt;% ns_adp_puts [ns_adp_eval {&amp;lt;% ... %&amp;gt;}] %&amp;gt; or use &amp;lt;% %&amp;gt; script within the body of a fancy tag.  Note that there is a known issue in that only a single inner instance of an adp tag is supported - see [http://sourceforge.net/tracker/?func=detail&amp;amp;aid=2958550&amp;amp;group_id=3152&amp;amp;atid=103152 Bug #2958550].&lt;br /&gt;
* Introduced a better command name to clear long-standing confusion between the previous registertag commands: '''[[ns_adp_registerscript]]''' instead of ns_register_adptag.&lt;br /&gt;
* Added '''[[ns_adp_registerproc]]''' which is similar to ns_adp_registerscript but the procedure receives individual arguments instead of an ns_set.&lt;br /&gt;
* Added output buffer improvements via new Ns_ConnFlush.  See '''[[ns_adp_close]]''' and '''[[ns_adp_flush]]'''&lt;br /&gt;
* Added automatic UTF-8 to output charset encoding.&lt;br /&gt;
* Added gzip output compression.&lt;br /&gt;
* Added streaming output in chunked-encoding format instead of the previous &amp;quot;response with no length&amp;quot; HTTP/1.0 method.&lt;br /&gt;
* Enhanced ADP error handling and reporting.&lt;br /&gt;
* Added ability to trace ADP pages.  Trace output is written to the server log.  See '''[[ns_adp_ctl]]''', which is a new command for configuring the ADP execution environment at runtime.&lt;br /&gt;
&lt;br /&gt;
=== Other Improvements: ===&lt;br /&gt;
&lt;br /&gt;
* New '''Ns_TclRegisterTrace''' API to enable callbacks at key state transition points in a much more natural way.  The [[ns_ictl]] command, which now has a second and better name that should be used going forward - '''[[ns_interp_ctl]]''', has been updated to support script-level traces.&lt;br /&gt;
* New '''Ns_Task''' API designed to replace the old Ns_SockCallback API which didn't do a very good job at managing timeouts along with I/O events.&lt;br /&gt;
* New '''[[ns_returnmoved]]''' command to return 301 http status code and redirect to a new URL.&lt;br /&gt;
* New '''[[ns_internalredirect]]''' command to restart connection processing with a new URL.&lt;br /&gt;
* 4.5.1 - Added '''ns_conn channel''' and '''ns_conn contentsentlength''' subcommands to [[ns_conn]] to allow raw communication via Tcl I/O to the remote client.&lt;br /&gt;
* New '''[[ns_cache]]''' command based on ideas from the [[nscache]] module.   This is semi-backward-compatible with the ns_cache module.  The new command does not support the nscache module's -thread functionality, nor can create virtual-server-specific caches - all caches are now serverwide.  More importantly, -timeout is no longer sliding.  For details of all the differences see '''[[ns_cache]]'''.&lt;br /&gt;
* New '''[[ns_loop_ctl]]''' command to monitor and manage ''for'', ''while'', and ''foreach'' loops.&lt;br /&gt;
* Added '''ns_ictl once''' subcommand to [[ns_ictl]] / [[ns_interp_ctl]] command to execute a script exactly once for a virtual server (i.e. at startup).&lt;br /&gt;
* Added '''ns_ictl package''' subcommand to [[ns_ictl]] / [[ns_interp_ctl]] command to handle loading of Tcl packages.&lt;br /&gt;
* Added '''ns_ictl cancel''' subcommand  to [[ns_ictl]] / [[ns_interp_ctl]] command to provide the ability to sendr async-cancel messages to any interpter listed in '''ns_ictl threads''' (another new subcommand)&lt;br /&gt;
* New '''[[ns_register_fastpath]]''' command to re-enable fastpath after a previous call to '''ns_register_proc'''.&lt;br /&gt;
* New '''[[ns_register_encoding]]''' command to enable mapping of method/URL combinations to specific charset encodings used to decode the request.&lt;br /&gt;
* 4.5.1 - New '''[[ns_register_cgi]]''' command to dynamically register a CGI executable to a url.&lt;br /&gt;
* New '''[[ns_driver]]''' command to get some stats on socket drivers.&lt;br /&gt;
* [[nszlib]] module is now integrated into the core and provides for on-the-fly gzip compression and other gzip facilities in '''[[ns_zlib]]'''&lt;br /&gt;
* -all switch added to '''[[ns_addrbyhost]]''' command.&lt;br /&gt;
* Added ability to access more AOLserver functionality from a tclsh (nsv_*, ns_thread, etc).&lt;br /&gt;
* Stack checking has returned.  In a multi-threaded application like AOLserver, stack checking is important for detecting buffer overruns and deep call trees blowing your thread stack, etc.&lt;br /&gt;
* More detailed information when logging uncaught Tcl errors.  Especially for connection threads, details of the HTTP request are logged to make diagnosing the root cause of errors easier.&lt;br /&gt;
&lt;br /&gt;
=== '''Changes in Behavior from 4.0:''' ===&lt;br /&gt;
&lt;br /&gt;
* Interpreter deallocate/cleanup process is different from 4.0 - in 4.0 global variables get unset and database handles get closed prior to running the rest of the oncleanup traces.  In 4.5, that happens last.&lt;br /&gt;
* Conn ids are no longer allocated/counted per pool per virtual server and only for queued connections - conn ids are now process-wide global for all pools and provide a counter of all requests, including those that did not get to be queued and processed.&lt;br /&gt;
* Global conn variable used to only be defined when serving a request for an adp file, now it's always defined.&lt;br /&gt;
* '''[[ns_adp_dir]]''' returns the value of [ns_info pageroot] when called outside of adp, whereas in 4.0 it returned &amp;quot;/&amp;quot; and in versions before, it threw an error.&lt;br /&gt;
* '''[[ns_adp_mimetype]]''' will work outside of adps as well now.&lt;br /&gt;
* '''[[ns_startcontent]]''' -type now requires encoding specification in addition to mime type - to workaround, use a version redefined in Tcl as described under '''[[ns_startcontent]]'''&lt;br /&gt;
* AOLserver 4.5 has a newer version of TclX Keyed List implementation which enforces certain requirements of keyed list that were never enforced before. Specifically, keylkeys will throw an error in AOLserver 4.5 if you attempt to give it a table-like list of lists that has more than 2 columns.&lt;br /&gt;
* Connection thread names no longer include the virtual server name and then the pool name - now it's just the pool name instead (thread names are visible in the server log and in /_stats). Scheduled threads don't list their virtual server name in 4.0 either.  Both these issues can be fixed as follows (this is included in the [http://aolserver.am.net/code/modules/ampools.adpx ampools] module):               &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
    ns_interp_ctl trace allocate {&lt;br /&gt;
        namespace eval ::ns {}&lt;br /&gt;
        set ::ns::thread_name [ns_thread name]&lt;br /&gt;
        ns_thread name &amp;quot;$::ns::thread_name[ns_info server]&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
    ns_interp_ctl trace deallocate {&lt;br /&gt;
        if {[info exists ::ns::thread_name]} {&lt;br /&gt;
            ns_thread name $::ns::thread_name&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
* In early versions of AOLserver 4.0, '''[[ns_tmpnam]]''' on Windows used to return names without a path (they were relative to current directory).  In later builds, Jamie Rasmussen changed it to use a temp directory using GetTempPath and GetTempFileName with a prefix which resulted in names like %TEMP%/AOL1234.tmp, where 1234 is derived from time.  In 4.5.1, [[ns_tmpnam]] uses _tempnam but without a prefix and also has no extension and names are just sequential integers with sequence apparently maintained per process, thus making them not very safe. This issue is fixed in version 4.5.2.&lt;br /&gt;
* Failure to call '''[[ns_adp_abort]]''' in an adp page after calling ns_return* will now result in a Tcl error being thrown and logged.  On the other hand, without a patch from Tom Jackson (portions of which are included in version 4.5.2), ns_adp_abort itself would throw an error.  In addition, adp flush errors (i.e. due to the client no longer being connected) now also result in Tcl errors being thrown and logged. These benign errors can be suppresed using the IgnoreFinalFlushErrors setting in version 4.5.2.&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=What%27s_new_in_4.5&amp;diff=5849</id>
		<title>What's new in 4.5</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=What%27s_new_in_4.5&amp;diff=5849"/>
		<updated>2010-06-23T04:17:48Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a fairly comprehensive list of new features and changes in AOLserver 4.5 and 4.5.1 (compared to 4.0).  If you know of anything that is missing, please add it.&lt;br /&gt;
&lt;br /&gt;
=== Connection Management: ===&lt;br /&gt;
&lt;br /&gt;
These two commands can be used together to map slow running requests to a specific pool and to set limits to avoid overload.&lt;br /&gt;
&lt;br /&gt;
* New '''[[ns_pools]]''' command to map method/URL's to specific thread pools.&lt;br /&gt;
* New '''[[ns_limits]]''' command  control the number of threads executing and/or waiting for execution by method/URL.&lt;br /&gt;
*'''Note:''' The new scheme does not pick up connection thread pool configurations from earlier versions of AOLServer. Please see the new example configuration files, and the documentation for [[ns_pools]] and [[ns_limits]], for instructions in upgrading your configuration.  &lt;br /&gt;
** As of 1 August 2007, the HEAD revision contains &amp;quot;pools.tcl&amp;quot;, which will handle many pre-4.5 configurations.&lt;br /&gt;
** There are known issues when using this feature in conjunction with virtual servers; see the SourceForge bug list (and development mailing list archive) for details.&lt;br /&gt;
&lt;br /&gt;
=== I/O Features: ===&lt;br /&gt;
&lt;br /&gt;
* New '''Ns_QueueWait''' API to enable event-driven callbacks in the driver thread before dispatching to pools for processing.&lt;br /&gt;
&lt;br /&gt;
:The allows drivers to augment data received from the client (headers, request, content) with additional data fetched over the network (likely stored in the new Ns_Cls &amp;quot;connection local storage&amp;quot; API's) before dispatching to the connection threads.  An example would be to add certain personalization data received via a web service. The rationale here is that I/O events are cheap so do those upfront instead of having expensive connection threads burdened with wasteful blocking I/O.  This is a somewhat obscure and technical interface.&lt;br /&gt;
&lt;br /&gt;
* Added ability to manage larger file uploads by spooling to a temporary file (currenty not for Windows).&lt;br /&gt;
&lt;br /&gt;
* New '''[[nsproxy]]''' module which provides the '''ns_proxy''' command which enables sending Tcl scripts to a proxy process connected via a pipe. The proxy includes core Tcl commands as well as AOLserver commands from the libnsd library. Evaluating scripts in a proxy process can be used to isolate and/or timeout thread-unsafe or otherwise unsafe 3rd party code.&lt;br /&gt;
&lt;br /&gt;
=== ADP Improvements: ===&lt;br /&gt;
&lt;br /&gt;
* Added a new execution caching technique at the '''[[ns_adp_include]]''' level which allows you to save the results of execution of an included ADP and includes below that for reuse on subsequent connections up to a specified time.&lt;br /&gt;
* Added '''singlescript''' config option which turns ADP pages into a single script enabling syntax such as &amp;quot;&amp;lt;% foreach e $list { %&amp;gt; element &amp;lt;%= $e %&amp;gt; here &amp;lt;% } %&amp;gt;&amp;quot;.&lt;br /&gt;
* Added support for nested adp tags, i.e. you can now do  &amp;lt;% ns_adp_puts [ns_adp_eval {&amp;lt;% ... %&amp;gt;}] %&amp;gt; or use &amp;lt;% %&amp;gt; script within the body of a fancy tag.  Note that there is a known issue in that only a single inner instance of an adp tag is supported - see [http://sourceforge.net/tracker/?func=detail&amp;amp;aid=2958550&amp;amp;group_id=3152&amp;amp;atid=103152 Bug #2958550].&lt;br /&gt;
* Introduced a better command name to clear long-standing confusion between the previous registertag commands: '''[[ns_adp_registerscript]]''' instead of ns_register_adptag.&lt;br /&gt;
* Added '''[[ns_adp_registerproc]]''' which is similar to ns_adp_registerscript but the procedure receives individual arguments instead of an ns_set.&lt;br /&gt;
* Added output buffer improvements via new Ns_ConnFlush.  See '''[[ns_adp_close]]''' and '''[[ns_adp_flush]]'''&lt;br /&gt;
* Added automatic UTF-8 to output charset encoding.&lt;br /&gt;
* Added gzip output compression.&lt;br /&gt;
* Added streaming output in chunked-encoding format instead of the previous &amp;quot;response with no length&amp;quot; HTTP/1.0 method.&lt;br /&gt;
* Enhanced ADP error handling and reporting.&lt;br /&gt;
* Added ability to trace ADP pages.  Trace output is written to the server log.  See '''[[ns_adp_ctl]]''', which is a new command for configuring the ADP execution environment at runtime.&lt;br /&gt;
&lt;br /&gt;
=== Other Improvements: ===&lt;br /&gt;
&lt;br /&gt;
* New '''Ns_TclRegisterTrace''' API to enable callbacks at key state transition points in a much more natural way.  The [[ns_ictl]] command, which now has a second and better name that should be used going forward - '''[[ns_interp_ctl]]''', has been updated to support script-level traces.&lt;br /&gt;
* New '''Ns_Task''' API designed to replace the old Ns_SockCallback API which didn't do a very good job at managing timeouts along with I/O events.&lt;br /&gt;
* New '''[[ns_returnmoved]]''' command to return 301 http status code and redirect to a new URL.&lt;br /&gt;
* New '''[[ns_internalredirect]]''' command to restart connection processing with a new URL.&lt;br /&gt;
* 4.5.1 - Added '''ns_conn channel''' and '''ns_conn contentsentlength''' subcommands to [[ns_conn]] to allow raw communication via Tcl I/O to the remote client.&lt;br /&gt;
* New '''[[ns_cache]]''' command based on ideas from the [[nscache]] module.   This is semi-backward-compatible with the ns_cache module.  The new command does not support the nscache module's -thread functionality, nor can create virtual-server-specific caches - all caches are now serverwide.  More importantly, -timeout is no longer sliding.  For details of all the differences see '''[[ns_cache]]'''.&lt;br /&gt;
* New '''[[ns_loop_ctl]]''' command to monitor and manage ''for'', ''while'', and ''foreach'' loops.&lt;br /&gt;
* Added '''ns_ictl once''' subcommand to [[ns_ictl]] / [[ns_interp_ctl]] command to execute a script exactly once for a virtual server (i.e. at startup).&lt;br /&gt;
* Added '''ns_ictl package''' subcommand to [[ns_ictl]] / [[ns_interp_ctl]] command to handle loading of Tcl packages.&lt;br /&gt;
* Added '''ns_ictl cancel''' subcommand  to [[ns_ictl]] / [[ns_interp_ctl]] command to provide the ability to sendr async-cancel messages to any interpter listed in '''ns_ictl threads''' (another new subcommand)&lt;br /&gt;
* New '''[[ns_register_fastpath]]''' command to re-enable fastpath after a previous call to '''ns_register_proc'''.&lt;br /&gt;
* New '''[[ns_register_encoding]]''' command to enable mapping of method/URL combinations to specific charset encodings used to decode the request.&lt;br /&gt;
* 4.5.1 - New '''[[ns_register_cgi]]''' command to dynamically register a CGI executable to a url.&lt;br /&gt;
* New '''[[ns_driver]]''' command to get some stats on socket drivers.&lt;br /&gt;
* [[nszlib]] module is now integrated into the core and provides for on-the-fly gzip compression and other gzip facilities in '''[[ns_zlib]]'''&lt;br /&gt;
* -all switch added to '''[[ns_addrbyhost]]''' command.&lt;br /&gt;
* Added ability to access more AOLserver functionality from a tclsh (nsv_*, ns_thread, etc).&lt;br /&gt;
* Stack checking has returned.  In a multi-threaded application like AOLserver, stack checking is important for detecting buffer overruns and deep call trees blowing your thread stack, etc.&lt;br /&gt;
* More detailed information when logging uncaught Tcl errors.  Especially for connection threads, details of the HTTP request are logged to make diagnosing the root cause of errors easier.&lt;br /&gt;
&lt;br /&gt;
=== '''Changes in Behavior from 4.0''' ===&lt;br /&gt;
&lt;br /&gt;
* Interpreter deallocate/cleanup process is different from 4.0 - in 4.0 global variables get unset and database handles get closed prior to running the rest of the oncleanup traces.  In 4.5, that happens last.&lt;br /&gt;
* Conn ids are no longer allocated/counted per pool per virtual server and only for queued connections - conn ids are now process-wide global for all pools and provide a counter of all requests, including those that did not get to be queued and processed.&lt;br /&gt;
* Global conn variable used to only be defined when serving a request for an adp file, now it's always defined.&lt;br /&gt;
* '''[[ns_adp_dir]]''' returns the value of [ns_info pageroot] when called outside of adp, whereas in 4.0 it returned &amp;quot;/&amp;quot; and in versions before, it threw an error.&lt;br /&gt;
* '''[[ns_adp_mimetype]]''' will work outside of adps as well now.&lt;br /&gt;
* '''[[ns_startcontent]]''' -type now requires encoding specification in addition to mime type - to workaround, use a version redefined in Tcl as described under '''[[ns_startcontent]]'''&lt;br /&gt;
* AOLserver 4.5 has a newer version of TclX Keyed List implementation which enforces certain requirements of keyed list that were never enforced before. Specifically, keylkeys will throw an error in AOLserver 4.5 if you attempt to give it a table-like list of lists that has more than 2 columns.&lt;br /&gt;
* Connection thread names no longer include the virtual server name and then the pool name - now it's just the pool name instead (thread names are visible in the server log and in /_stats). Scheduled threads don't list their virtual server name in 4.0 either.  Both these issues can be fixed as follows (this is included in the [http://aolserver.am.net/code/modules/ampools.adpx ampools] module):               &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
    ns_interp_ctl trace allocate {&lt;br /&gt;
        namespace eval ::ns {}&lt;br /&gt;
        set ::ns::thread_name [ns_thread name]&lt;br /&gt;
        ns_thread name &amp;quot;$::ns::thread_name[ns_info server]&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
    ns_interp_ctl trace deallocate {&lt;br /&gt;
        if {[info exists ::ns::thread_name]} {&lt;br /&gt;
            ns_thread name $::ns::thread_name&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
* In early versions of AOLserver 4.0, '''[[ns_tmpnam]]''' on Windows used to return names without a path (they were relative to current directory).  In later builds, Jamie Rasmussen changed it to use a temp directory using GetTempPath and GetTempFileName with a prefix which resulted in names like %TEMP%/AOL1234.tmp, where 1234 is derived from time.  In 4.5.1, [[ns_tmpnam]] uses _tempnam but without a prefix and also has no extension and names are just sequential integers with sequence apparently maintained per process, thus making them not very safe. This issue is fixed in version 4.5.2.&lt;br /&gt;
*&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=What%27s_new_in_4.5&amp;diff=5848</id>
		<title>What's new in 4.5</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=What%27s_new_in_4.5&amp;diff=5848"/>
		<updated>2010-06-23T04:12:34Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a fairly comprehensive list of new features and changes in AOLserver 4.5 and 4.5.1 (compared to 4.0).  If you know of anything that is missing, please add it.&lt;br /&gt;
&lt;br /&gt;
=== Connection Management: ===&lt;br /&gt;
&lt;br /&gt;
These two commands can be used together to map slow running requests to a specific pool and to set limits to avoid overload.&lt;br /&gt;
&lt;br /&gt;
* New '''[[ns_pools]]''' command to map method/URL's to specific thread pools.&lt;br /&gt;
* New '''[[ns_limits]]''' command  control the number of threads executing and/or waiting for execution by method/URL.&lt;br /&gt;
*'''Note:''' The new scheme does not pick up connection thread pool configurations from earlier versions of AOLServer. Please see the new example configuration files, and the documentation for [[ns_pools]] and [[ns_limits]], for instructions in upgrading your configuration.  &lt;br /&gt;
** As of 1 August 2007, the HEAD revision contains &amp;quot;pools.tcl&amp;quot;, which will handle many pre-4.5 configurations.&lt;br /&gt;
** There are known issues when using this feature in conjunction with virtual servers; see the SourceForge bug list (and development mailing list archive) for details.&lt;br /&gt;
&lt;br /&gt;
=== I/O Features: ===&lt;br /&gt;
&lt;br /&gt;
* New '''Ns_QueueWait''' API to enable event-driven callbacks in the driver thread before dispatching to pools for processing.&lt;br /&gt;
&lt;br /&gt;
:The allows drivers to augment data received from the client (headers, request, content) with additional data fetched over the network (likely stored in the new Ns_Cls &amp;quot;connection local storage&amp;quot; API's) before dispatching to the connection threads.  An example would be to add certain personalization data received via a web service. The rationale here is that I/O events are cheap so do those upfront instead of having expensive connection threads burdened with wasteful blocking I/O.  This is a somewhat obscure and technical interface.&lt;br /&gt;
&lt;br /&gt;
* Added ability to manage larger file uploads by spooling to a temporary file (currenty not for Windows).&lt;br /&gt;
&lt;br /&gt;
* New '''[[nsproxy]]''' module which provides the '''ns_proxy''' command which enables sending Tcl scripts to a proxy process connected via a pipe. The proxy includes core Tcl commands as well as AOLserver commands from the libnsd library. Evaluating scripts in a proxy process can be used to isolate and/or timeout thread-unsafe or otherwise unsafe 3rd party code.&lt;br /&gt;
&lt;br /&gt;
=== ADP Improvements: ===&lt;br /&gt;
&lt;br /&gt;
* Added a new execution caching technique at the '''[[ns_adp_include]]''' level which allows you to save the results of execution of an included ADP and includes below that for reuse on subsequent connections up to a specified time.&lt;br /&gt;
* Added '''singlescript''' config option which turns ADP pages into a single script enabling syntax such as &amp;quot;&amp;lt;% foreach e $list { %&amp;gt; element &amp;lt;%= $e %&amp;gt; here &amp;lt;% } %&amp;gt;&amp;quot;.&lt;br /&gt;
* Added support for nested adp tags, i.e. you can now do  &amp;lt;% ns_adp_puts [ns_adp_eval {&amp;lt;% ... %&amp;gt;}] %&amp;gt; or use &amp;lt;% %&amp;gt; script within the body of a fancy tag.  Note that there is a known issue in that only a single inner instance of an adp tag is supported - see [http://sourceforge.net/tracker/?func=detail&amp;amp;aid=2958550&amp;amp;group_id=3152&amp;amp;atid=103152 Bug #2958550].&lt;br /&gt;
* Introduced a better command name to clear long-standing confusion between the previous registertag commands: '''[[ns_adp_registerscript]]''' instead of ns_register_adptag.&lt;br /&gt;
* Added '''[[ns_adp_registerproc]]''' which is similar to ns_adp_registerscript but the procedure receives individual arguments instead of an ns_set.&lt;br /&gt;
* Added output buffer improvements via new Ns_ConnFlush.  See '''[[ns_adp_close]]''' and '''[[ns_adp_flush]]'''&lt;br /&gt;
* Added automatic UTF-8 to output charset encoding.&lt;br /&gt;
* Added gzip output compression.&lt;br /&gt;
* Added streaming output in chunked-encoding format instead of the previous &amp;quot;response with no length&amp;quot; HTTP/1.0 method.&lt;br /&gt;
* Enhanced ADP error handling and reporting.&lt;br /&gt;
* Added ability to trace ADP pages.  Trace output is written to the server log.  See '''[[ns_adp_ctl]]''', which is a new command for configuring the ADP execution environment at runtime.&lt;br /&gt;
&lt;br /&gt;
=== Other Improvements: ===&lt;br /&gt;
&lt;br /&gt;
* New '''Ns_TclRegisterTrace''' API to enable callbacks at key state transition points in a much more natural way.  The [[ns_ictl]] command, which now has a second and better name that should be used going forward - '''[[ns_interp_ctl]]''', has been updated to support script-level traces.&lt;br /&gt;
* New '''Ns_Task''' API designed to replace the old Ns_SockCallback API which didn't do a very good job at managing timeouts along with I/O events.&lt;br /&gt;
* New '''[[ns_returnmoved]]''' command to return 301 http status code and redirect to a new URL.&lt;br /&gt;
* New '''[[ns_internalredirect]]''' command to restart connection processing with a new URL.&lt;br /&gt;
* 4.5.1 - Added '''ns_conn channel''' and '''ns_conn contentsentlength''' subcommands to [[ns_conn]] to allow raw communication via Tcl I/O to the remote client.&lt;br /&gt;
* New '''[[ns_cache]]''' command based on ideas from the [[nscache]] module.   This is semi-backward-compatible with the ns_cache module.  The new command does not support the nscache module's -thread functionality, nor can create virtual-server-specific caches - all caches are now serverwide.  More importantly, -timeout is no longer sliding.  For details of all the differences see '''[[ns_cache]]'''.&lt;br /&gt;
* New '''[[ns_loop_ctl]]''' command to monitor and manage ''for'', ''while'', and ''foreach'' loops.&lt;br /&gt;
* Added '''ns_ictl once''' subcommand to [[ns_ictl]] / [[ns_interp_ctl]] command to execute a script exactly once for a virtual server (i.e. at startup).&lt;br /&gt;
* Added '''ns_ictl package''' subcommand to [[ns_ictl]] / [[ns_interp_ctl]] command to handle loading of Tcl packages.&lt;br /&gt;
* Added '''ns_ictl cancel''' subcommand  to [[ns_ictl]] / [[ns_interp_ctl]] command to provide the ability to sendr async-cancel messages to any interpter listed in '''ns_ictl threads''' (another new subcommand)&lt;br /&gt;
* New '''[[ns_register_fastpath]]''' command to re-enable fastpath after a previous call to '''ns_register_proc'''.&lt;br /&gt;
* New '''[[ns_register_encoding]]''' command to enable mapping of method/URL combinations to specific charset encodings used to decode the request.&lt;br /&gt;
* 4.5.1 - New '''[[ns_register_cgi]]''' command to dynamically register a CGI executable to a url.&lt;br /&gt;
* New '''[[ns_driver]]''' command to get some stats on socket drivers.&lt;br /&gt;
* [[nszlib]] module is now integrated into the core and provides for on-the-fly gzip compression and other gzip facilities in '''[[ns_zlib]]'''&lt;br /&gt;
* -all switch added to '''[[ns_addrbyhost]]''' command.&lt;br /&gt;
* Added ability to access more AOLserver functionality from a tclsh (nsv_*, ns_thread, etc).&lt;br /&gt;
* Stack checking has returned.  In a multi-threaded application like AOLserver, stack checking is important for detecting buffer overruns and deep call trees blowing your thread stack, etc.&lt;br /&gt;
* More detailed information when logging uncaught Tcl errors.  Especially for connection threads, details of the HTTP request are logged to make diagnosing the root cause of errors easier.&lt;br /&gt;
&lt;br /&gt;
=== '''Changes in Behavior from 4.0''' ===&lt;br /&gt;
&lt;br /&gt;
* Interpreter deallocate/cleanup process is different from 4.0 - in 4.0 global variables get unset and database handles get closed prior to running the rest of the oncleanup traces.  In 4.5, that happens last.&lt;br /&gt;
* Conn ids are no longer allocated/counted per pool per virtual server and only for queued connections - conn ids are now process-wide global for all pools and provide a counter of all requests, including those that did not get to be queued and processed.&lt;br /&gt;
* Global conn variable used to only be defined when serving a request for an adp file, now it's always defined.&lt;br /&gt;
* '''[[ns_adp_dir]]''' returns the value of [ns_info pageroot] when called outside of adp, whereas in 4.0 it returned &amp;quot;/&amp;quot; and in versions before, it threw an error.&lt;br /&gt;
* '''[[ns_adp_mimetype]]''' will work outside of adps as well now.&lt;br /&gt;
* '''[[ns_startcontent]]''' -type now requires encoding specification in addition to mime type - to workaround, use a version redefined in Tcl as described under '''[[ns_startcontent]]'''&lt;br /&gt;
* AOLserver 4.5 has a newer version of TclX Keyed List implementation which enforces certain requirements of keyed list that were never enforced before. Specifically, keylkeys will throw an error in AOLserver 4.5 if you attempt to give it a table-like list of lists that has more than 2 columns.&lt;br /&gt;
* Connection thread names no longer include the virtual server name and then the pool name - now it's just the pool name instead (thread names are visible in the server log and in /_stats). Scheduled threads don't list their virtual server name in 4.0 either.  Both these issues can be fixed as follows (this is included in the [http://aolserver.am.net/code/modules/ampools.adpx ampools] module):               &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
    ns_interp_ctl trace allocate {&lt;br /&gt;
        namespace eval ::ns {}&lt;br /&gt;
        set ::ns::thread_name [ns_thread name]&lt;br /&gt;
        ns_thread name &amp;quot;&amp;quot;$::ns::thread_name[ns_info server]&amp;quot;&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
    ns_interp_ctl trace deallocate {&lt;br /&gt;
        if {[info exists ::ns::thread_name]} {&lt;br /&gt;
            ns_thread name $::ns::thread_name&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=What%27s_new_in_4.5&amp;diff=5847</id>
		<title>What's new in 4.5</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=What%27s_new_in_4.5&amp;diff=5847"/>
		<updated>2010-06-23T03:18:02Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a fairly comprehensive list of new features and changes in AOLserver 4.5 and 4.5.1 (compared to 4.0).  If you know of anything that is missing, please add it.&lt;br /&gt;
&lt;br /&gt;
=== Connection Management: ===&lt;br /&gt;
&lt;br /&gt;
These two commands can be used together to map slow running requests to a specific pool and to set limits to avoid overload.&lt;br /&gt;
&lt;br /&gt;
* New '''[[ns_pools]]''' command to map method/URL's to specific thread pools.&lt;br /&gt;
* New '''[[ns_limits]]''' command  control the number of threads executing and/or waiting for execution by method/URL.&lt;br /&gt;
*'''Note:''' The new scheme does not pick up connection thread pool configurations from earlier versions of AOLServer. Please see the new example configuration files, and the documentation for [[ns_pools]] and [[ns_limits]], for instructions in upgrading your configuration.  &lt;br /&gt;
** As of 1 August 2007, the HEAD revision contains &amp;quot;pools.tcl&amp;quot;, which will handle many pre-4.5 configurations.&lt;br /&gt;
** There are known issues when using this feature in conjunction with virtual servers; see the SourceForge bug list (and development mailing list archive) for details.&lt;br /&gt;
&lt;br /&gt;
=== I/O Features: ===&lt;br /&gt;
&lt;br /&gt;
* New '''Ns_QueueWait''' API to enable event-driven callbacks in the driver thread before dispatching to pools for processing.&lt;br /&gt;
&lt;br /&gt;
:The allows drivers to augment data received from the client (headers, request, content) with additional data fetched over the network (likely stored in the new Ns_Cls &amp;quot;connection local storage&amp;quot; API's) before dispatching to the connection threads.  An example would be to add certain personalization data received via a web service. The rationale here is that I/O events are cheap so do those upfront instead of having expensive connection threads burdened with wasteful blocking I/O.  This is a somewhat obscure and technical interface.&lt;br /&gt;
&lt;br /&gt;
* Added ability to manage larger file uploads by spooling to a temporary file (currenty not for Windows).&lt;br /&gt;
&lt;br /&gt;
* New '''[[nsproxy]]''' module which provides the '''ns_proxy''' command which enables sending Tcl scripts to a proxy process connected via a pipe. The proxy includes core Tcl commands as well as AOLserver commands from the libnsd library. Evaluating scripts in a proxy process can be used to isolate and/or timeout thread-unsafe or otherwise unsafe 3rd party code.&lt;br /&gt;
&lt;br /&gt;
=== ADP Improvements: ===&lt;br /&gt;
&lt;br /&gt;
* Added a new execution caching technique at the '''[[ns_adp_include]]''' level which allows you to save the results of execution of an included ADP and includes below that for reuse on subsequent connections up to a specified time.&lt;br /&gt;
* Added '''singlescript''' config option which turns ADP pages into a single script enabling syntax such as &amp;quot;&amp;lt;% foreach e $list { %&amp;gt; element &amp;lt;%= $e %&amp;gt; here &amp;lt;% } %&amp;gt;&amp;quot;.&lt;br /&gt;
* Added support for nested adp tags, i.e. you can now do  &amp;lt;% ns_adp_puts [ns_adp_eval {&amp;lt;% ... %&amp;gt;}] %&amp;gt; or use &amp;lt;% %&amp;gt; script within the body of a fancy tag.  Note that there is a known issue in that only a single inner instance of an adp tag is supported - see [http://sourceforge.net/tracker/?func=detail&amp;amp;aid=2958550&amp;amp;group_id=3152&amp;amp;atid=103152 Bug #2958550].&lt;br /&gt;
* Introduced a better command name to clear long-standing confusion between the previous registertag commands: '''[[ns_adp_registerscript]]''' instead of ns_register_adptag.&lt;br /&gt;
* Added '''[[ns_adp_registerproc]]''' which is similar to ns_adp_registerscript but the procedure receives individual arguments instead of an ns_set.&lt;br /&gt;
* Added output buffer improvements via new Ns_ConnFlush.  See '''[[ns_adp_close]]''' and '''[[ns_adp_flush]]'''&lt;br /&gt;
* Added automatic UTF-8 to output charset encoding.&lt;br /&gt;
* Added gzip output compression.&lt;br /&gt;
* Added streaming output in chunked-encoding format instead of the previous &amp;quot;response with no length&amp;quot; HTTP/1.0 method.&lt;br /&gt;
* Enhanced ADP error handling and reporting.&lt;br /&gt;
* Added ability to trace ADP pages.  Trace output is written to the server log.  See '''[[ns_adp_ctl]]''', which is a new command for configuring the ADP execution environment at runtime.&lt;br /&gt;
&lt;br /&gt;
=== Other Improvements: ===&lt;br /&gt;
&lt;br /&gt;
* New '''Ns_TclRegisterTrace''' API to enable callbacks at key state transition points in a much more natural way.  The [[ns_ictl]] command, which now has a second and better name that should be used going forward - '''[[ns_interp_ctl]]''', has been updated to support script-level traces.&lt;br /&gt;
* New '''Ns_Task''' API designed to replace the old Ns_SockCallback API which didn't do a very good job at managing timeouts along with I/O events.&lt;br /&gt;
* New '''[[ns_returnmoved]]''' command to return 301 http status code and redirect to a new URL.&lt;br /&gt;
* New '''[[ns_internalredirect]]''' command to restart connection processing with a new URL.&lt;br /&gt;
* 4.5.1 - Added '''ns_conn channel''' and '''ns_conn contentsentlength''' subcommands to [[ns_conn]] to allow raw communication via Tcl I/O to the remote client.&lt;br /&gt;
* New '''[[ns_cache]]''' command based on ideas from the [[nscache]] module.   This is semi-backward-compatible with the ns_cache module (differences are described in detail in '''[[ns_cache]]''').&lt;br /&gt;
* New '''[[ns_loop_ctl]]''' command to monitor and manage ''for'', ''while'', and ''foreach'' loops.&lt;br /&gt;
* Added '''ns_ictl once''' subcommand to [[ns_ictl]] / [[ns_interp_ctl]] command to execute a script exactly once for a virtual server (i.e. at startup).&lt;br /&gt;
* Added '''ns_ictl package''' subcommand to [[ns_ictl]] / [[ns_interp_ctl]] command to handle loading of Tcl packages.&lt;br /&gt;
* Added '''ns_ictl cancel''' subcommand  to [[ns_ictl]] / [[ns_interp_ctl]] command to provide the ability to sendr async-cancel messages to any interpter listed in '''ns_ictl threads''' (another new subcommand)&lt;br /&gt;
* New '''[[ns_register_fastpath]]''' command to re-enable fastpath after a previous call to '''ns_register_proc'''.&lt;br /&gt;
* New '''[[ns_register_encoding]]''' command to enable mapping of method/URL combinations to specific charset encodings used to decode the request.&lt;br /&gt;
* 4.5.1 - New '''[[ns_register_cgi]]''' command to dynamically register a CGI executable to a url.&lt;br /&gt;
* New '''[[ns_driver]]''' command to get some stats on socket drivers.&lt;br /&gt;
* [[nszlib]] module is now integrated into the core and provides for on-the-fly gzip compression and other gzip facilities in '''[[ns_zlib]]'''&lt;br /&gt;
* -all switch added to '''[[ns_addrbyhost]]''' command.&lt;br /&gt;
* Added ability to access more AOLserver functionality from a tclsh (nsv_*, ns_thread, etc).&lt;br /&gt;
* Stack checking has returned.  In a multi-threaded application like AOLserver, stack checking is important for detecting buffer overruns and deep call trees blowing your thread stack, etc.&lt;br /&gt;
* More detailed information when logging uncaught Tcl errors.  Especially for connection threads, details of the HTTP request are logged to make diagnosing the root cause of errors easier.&lt;br /&gt;
&lt;br /&gt;
=== '''Changes in Behavior from 4.0''' ===&lt;br /&gt;
&lt;br /&gt;
* Interpreter deallocate/cleanup process is different from 4.0 - in 4.0 global variables get unset and database handles get closed prior to running the rest of the oncleanup traces.  In 4.5, that happens last.&lt;br /&gt;
* conn ids are no longer allocated/counted per pool per virtual server and only for queued connections - conn ids are now process-wide global for all pools and provide a counter of all requests, including those that did not get to be queued and processed&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Tcl_API&amp;diff=5846</id>
		<title>Tcl API</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Tcl_API&amp;diff=5846"/>
		<updated>2010-06-21T21:47:11Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Links to all of the Tcl commands provided by the AOLserver core &amp;quot;out of the box&amp;quot;.  To view a complete list of these commands in alphabetical order, try the [[:Category:Core Tcl API]] page.&lt;br /&gt;
&lt;br /&gt;
Like what you see here?  Want to try your hand at documenting a command, too?  Here's [[how to document the core Tcl API]].&lt;br /&gt;
&lt;br /&gt;
You can [http://aolserver.am.net/downloads/tcl-core.tip download] a syntax method tip / auto-completion file (from aolserver.am.net) for the free [http://www.activestate.com/komodo-edit Komodo Edit 5] (includes Tcl, all of ns_* APIs and some popular AOLserver modules and Tcl packages).  Place it into ''&amp;quot;%ProgramFiles%\ActiveState Komodo Edit 5\lib\support\tcl\&amp;quot;'' replacing the default Tcl-only file that comes with Komodo Edit.&lt;br /&gt;
&lt;br /&gt;
== ADP, Request and Response-oriented commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_adp_abort]], [[ns_adp_append]], [[ns_adp_argc]], [[ns_adp_argv]], [[ns_adp_bind_args]], [[ns_adp_break]], [[ns_adp_close]], [[ns_adp_ctl]], [[ns_adp_debug]], [[ns_adp_debuginit]], [[ns_adp_dir]], [[ns_adp_dump]], [[ns_adp_eval]], [[ns_adp_exception]], [[ns_adp_flush]], [[ns_adp_include]], [[ns_adp_mime]], [[ns_adp_mimetype]], [[ns_adp_parse]], [[ns_adp_puts]] ([[ns_puts]]), [[ns_adp_return]], [[ns_adp_safeeval]], [[ns_adp_stats]], [[ns_adp_stream]], [[ns_adp_tell]], [[ns_adp_trunc]]&lt;br /&gt;
&lt;br /&gt;
:'''Registered (fka fancy) ADP tags:'''&lt;br /&gt;
:[[ns_adp_registeradp]] (same as deprecated [[ns_adp_registertag]])&lt;br /&gt;
:[[ns_adp_registerproc]]&lt;br /&gt;
:[[ns_adp_registerscript]] (same as deprecated [[ns_register_adptag]]) &lt;br /&gt;
&lt;br /&gt;
:'''Request information and received content''':&lt;br /&gt;
: [[ns_conn]], [[ns_conncptofp]] (same as deprecated [[ns_writecontent]])&lt;br /&gt;
: [[ns_getform]], [[ns_getformfile]]&lt;br /&gt;
: [[ns_queryexists]], [[ns_queryget]], [[ns_querygetall]]&lt;br /&gt;
: [[ns_browsermatch]]&lt;br /&gt;
&lt;br /&gt;
:'''Standard response commands:'''&lt;br /&gt;
: [[ns_return]], [[ns_returnadminnotice]], [[ns_returnbadrequest]], [[ns_returnerror]], [[ns_returnfile]], [[ns_returnforbidden]], [[ns_returnfp]], [[ns_returnmoved]], [[ns_returnnotfound]], [[ns_returnnotice]], [[ns_returnok]], [[ns_returnredirect]], [[ns_returnunauthorized]]&lt;br /&gt;
&lt;br /&gt;
:'''More control over response:'''&lt;br /&gt;
: [[ns_setexpires]], [[ns_updateheader]], [[ns_respond]]&lt;br /&gt;
&lt;br /&gt;
:'''Manual response:'''&lt;br /&gt;
: [[ns_headers]], [[ns_startcontent]], [[ns_write]], [[ns_writefp]] / [[ns_connsendfp]] (deprecated)&lt;br /&gt;
&lt;br /&gt;
== Cache commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_cache]], [[ns_cache_flush]], [[ns_cache_keys]], [[ns_cache_names]], [[ns_cache_size]], [[ns_cache_stats]]&lt;br /&gt;
&lt;br /&gt;
== Concurrent programming commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_cond]], [[ns_critsec]], [[ns_event]], [[ns_job]], [[ns_kill]], [[ns_mutex]], [[ns_sema]], [[ns_thread]]&lt;br /&gt;
&lt;br /&gt;
== Custom data structures and variable manipulation commands ==&lt;br /&gt;
* TclX keyed lists:&lt;br /&gt;
&lt;br /&gt;
: [[keyldel]], [[keylget]], [[keylkeys]], [[keylset]]&lt;br /&gt;
* [[Thread-shared Variables]] (NSVs):&lt;br /&gt;
&lt;br /&gt;
: [[nsv_get]], [[nsv_exists]], [[nsv_set]], [[nsv_incr]], [[nsv_append]], [[nsv_lappend]], [[nsv_array]], [[nsv_unset]], [[nsv_names]]&lt;br /&gt;
* Sets and multisets:&lt;br /&gt;
&lt;br /&gt;
: [[ns_findset]], [[ns_set]]&lt;br /&gt;
* ???&lt;br /&gt;
&lt;br /&gt;
: [[ns_share]], [[ns_var]]&lt;br /&gt;
&lt;br /&gt;
== Database commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_buildsqldate]], [[ns_buildsqltime]], [[ns_buildsqltimestamp]], [[ns_db]], [[ns_dbquotename]], [[ns_dbquotevalue]], [[ns_localsqltimestamp]], [[ns_parsesqldate]], [[ns_parsesqltime]], [[ns_parsesqltimestamp]], [[ns_writecsv]]&lt;br /&gt;
&lt;br /&gt;
== DNS lookup commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_addrbyhost]], [[ns_hostbyaddr]]&lt;br /&gt;
&lt;br /&gt;
== File manipulation commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_chmod]], [[ns_cp]], [[ns_ftruncate]], [[ns_link]], [[ns_mkdir]], [[ns_mktemp]], [[ns_normalizepath]], [[ns_openexcl]], [[ns_purgefiles]], [[ns_rename]], [[ns_rmdir]], [[ns_rollfile]], [[ns_symlink]], [[ns_tmpnam]], [[ns_truncate]], [[ns_unlink]]&lt;br /&gt;
&lt;br /&gt;
== HTML manipulation commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_formvalueput]], [[ns_hrefs]], [[ns_htmlselect]], [[ns_quotehtml]], [[ns_striphtml]], [[ns_tagelement]], [[ns_tagelementset]]&lt;br /&gt;
&lt;br /&gt;
== HTTP commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_http]], [[ns_httpget]], [[ns_httpopen]], [[ns_httppost]]&lt;br /&gt;
&lt;br /&gt;
== Image manipulation commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_gifsize]], [[ns_jpegsize]]&lt;br /&gt;
&lt;br /&gt;
== Internationalization (I18N) support commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_charsets]], [[ns_choosecharset]], [[ns_cookiecharset]], [[ns_encodingforcharset]], [[ns_encodingfortype]], [[ns_formfieldcharset]], [[ns_setformencoding]] / [[ns_urlcharset]]&lt;br /&gt;
&lt;br /&gt;
== Logging commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_accesslog]], [[ns_log]], [[ns_logctl]], [[ns_logroll]]&lt;br /&gt;
&lt;br /&gt;
== Request authorization commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_checkurl]], [[ns_requestauthorize]]&lt;br /&gt;
&lt;br /&gt;
== Request processing commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_register_adp]], [[ns_register_cgi]], [[ns_register_encoding]], [[ns_register_filter_error]], [[ns_register_fastpath]], [[ns_register_filter]], [[ns_register_filter_shortcut]] [[ns_register_proc]], [[ns_register_trace]], [[ns_unregister_adp]], [[ns_unregister_proc]]&lt;br /&gt;
&lt;br /&gt;
== Scheduling commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_after]], [[ns_atclose]], [[ns_atexit]], [[ns_atshutdown]], [[ns_atsignal]], [[ns_cancel]], [[ns_pause]], [[ns_resume]], [[ns_schedule_proc]], [[ns_schedule_daily]], [[ns_schedule_weekly]], [[ns_shutdown]], [[ns_unschedule_proc]]&lt;br /&gt;
&lt;br /&gt;
== Server configuration commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_config]], [[ns_configsection]], [[ns_configsections]], [[ns_library]], [[ns_limits]], [[ns_modulepath]], [[ns_param]], [[ns_pools]], [[ns_section]]&lt;br /&gt;
&lt;br /&gt;
== Server introspection commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_driver]], [[ns_env]], [[ns_info]], [[ns_server]], [[ns_stats]] (3.x only, defunct in 4.0+)&lt;br /&gt;
&lt;br /&gt;
== Socket I/O commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_sock]], [[ns_sockaccept]], [[ns_sockblocking]], [[ns_sockcallback]], [[ns_sockcheck]], [[ns_sockclose]], [[ns_sockdup]], [[ns_sockerrno]], [[ns_socketpair]], [[ns_sockioctl]], [[ns_socklisten]], [[ns_socklistencallback]], [[ns_socknbclose]], [[ns_socknonblocking]], [[ns_socknread]], [[ns_sockopen]], [[ns_sockpair]], [[ns_sockreadwait]], [[ns_sockselect]], [[ns_socksend]], [[ns_sockstrerror]]&lt;br /&gt;
&lt;br /&gt;
== Tcl channel management commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_chan]], [[ns_cleanupchans]], [[ns_getchannels]]&lt;br /&gt;
&lt;br /&gt;
== Tcl interpreter management commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_cleanup]], [[ns_eval]], [[ns_interp_ctl]] (4.5+) / [[ns_ictl]] (4.0), [[ns_init]], [[ns_loop_ctl]], [[ns_markfordelete]], [[ns_reinit]]&lt;br /&gt;
&lt;br /&gt;
== Time commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_fmttime]], [[ns_gmtime]], [[ns_httptime]], [[ns_localtime]], [[ns_parsehttptime]], [[ns_parsetime]], [[ns_time]]&lt;br /&gt;
   &lt;br /&gt;
== Uncategorized ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_cpfp]], [[ns_crypt]], [[ns_getcsv]], [[ns_geturl]], [[ns_guesstype]], [[ns_isformcached]], [[ns_issmallint]], [[ns_paren]], [[ns_parseheader]], [[ns_parsequery]], [[ns_rand]], [[ns_resetcachedform]], [[ns_sendmail]], [[ns_sleep]], [[ns_sourceproc]], [[ns_url2file]], [[ns_urldecode]], [[ns_urlencode]], [[ns_uudecode]], [[ns_uuencode]], [[ns_zlib]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Tcl_API&amp;diff=5845</id>
		<title>Tcl API</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Tcl_API&amp;diff=5845"/>
		<updated>2010-06-21T21:43:49Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Links to all of the Tcl commands provided by the AOLserver core &amp;quot;out of the box&amp;quot;.  To view a complete list of these commands in alphabetical order, try the [[:Category:Core Tcl API]] page.&lt;br /&gt;
&lt;br /&gt;
Like what you see here?  Want to try your hand at documenting a command, too?  Here's [[how to document the core Tcl API]].&lt;br /&gt;
&lt;br /&gt;
You can [http://aolserver.am.net/downloads/tcl-core.tip download] a syntax method tip / auto-completion file (from aolserver.am.net) for the free [http://www.activestate.com/komodo-edit Komodo Edit 5] (includes Tcl, all of ns_* APIs and some popular AOLserver modules and Tcl packages).&lt;br /&gt;
&lt;br /&gt;
== ADP, Request and Response-oriented commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_adp_abort]], [[ns_adp_append]], [[ns_adp_argc]], [[ns_adp_argv]], [[ns_adp_bind_args]], [[ns_adp_break]], [[ns_adp_close]], [[ns_adp_ctl]], [[ns_adp_debug]], [[ns_adp_debuginit]], [[ns_adp_dir]], [[ns_adp_dump]], [[ns_adp_eval]], [[ns_adp_exception]], [[ns_adp_flush]], [[ns_adp_include]], [[ns_adp_mime]], [[ns_adp_mimetype]], [[ns_adp_parse]], [[ns_adp_puts]] ([[ns_puts]]), [[ns_adp_return]], [[ns_adp_safeeval]], [[ns_adp_stats]], [[ns_adp_stream]], [[ns_adp_tell]], [[ns_adp_trunc]]&lt;br /&gt;
&lt;br /&gt;
:'''Registered (fka fancy) ADP tags:'''&lt;br /&gt;
:[[ns_adp_registeradp]] (same as deprecated [[ns_adp_registertag]])&lt;br /&gt;
:[[ns_adp_registerproc]]&lt;br /&gt;
:[[ns_adp_registerscript]] (same as deprecated [[ns_register_adptag]]) &lt;br /&gt;
&lt;br /&gt;
:'''Request information and received content''':&lt;br /&gt;
: [[ns_conn]], [[ns_conncptofp]] (same as deprecated [[ns_writecontent]])&lt;br /&gt;
: [[ns_getform]], [[ns_getformfile]]&lt;br /&gt;
: [[ns_queryexists]], [[ns_queryget]], [[ns_querygetall]]&lt;br /&gt;
: [[ns_browsermatch]]&lt;br /&gt;
&lt;br /&gt;
:'''Standard response commands:'''&lt;br /&gt;
: [[ns_return]], [[ns_returnadminnotice]], [[ns_returnbadrequest]], [[ns_returnerror]], [[ns_returnfile]], [[ns_returnforbidden]], [[ns_returnfp]], [[ns_returnmoved]], [[ns_returnnotfound]], [[ns_returnnotice]], [[ns_returnok]], [[ns_returnredirect]], [[ns_returnunauthorized]]&lt;br /&gt;
&lt;br /&gt;
:'''More control over response:'''&lt;br /&gt;
: [[ns_setexpires]], [[ns_updateheader]], [[ns_respond]]&lt;br /&gt;
&lt;br /&gt;
:'''Manual response:'''&lt;br /&gt;
: [[ns_headers]], [[ns_startcontent]], [[ns_write]], [[ns_writefp]] / [[ns_connsendfp]] (deprecated)&lt;br /&gt;
&lt;br /&gt;
== Cache commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_cache]], [[ns_cache_flush]], [[ns_cache_keys]], [[ns_cache_names]], [[ns_cache_size]], [[ns_cache_stats]]&lt;br /&gt;
&lt;br /&gt;
== Concurrent programming commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_cond]], [[ns_critsec]], [[ns_event]], [[ns_job]], [[ns_kill]], [[ns_mutex]], [[ns_sema]], [[ns_thread]]&lt;br /&gt;
&lt;br /&gt;
== Custom data structures and variable manipulation commands ==&lt;br /&gt;
* TclX keyed lists:&lt;br /&gt;
&lt;br /&gt;
: [[keyldel]], [[keylget]], [[keylkeys]], [[keylset]]&lt;br /&gt;
* [[Thread-shared Variables]] (NSVs):&lt;br /&gt;
&lt;br /&gt;
: [[nsv_get]], [[nsv_exists]], [[nsv_set]], [[nsv_incr]], [[nsv_append]], [[nsv_lappend]], [[nsv_array]], [[nsv_unset]], [[nsv_names]]&lt;br /&gt;
* Sets and multisets:&lt;br /&gt;
&lt;br /&gt;
: [[ns_findset]], [[ns_set]]&lt;br /&gt;
* ???&lt;br /&gt;
&lt;br /&gt;
: [[ns_share]], [[ns_var]]&lt;br /&gt;
&lt;br /&gt;
== Database commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_buildsqldate]], [[ns_buildsqltime]], [[ns_buildsqltimestamp]], [[ns_db]], [[ns_dbquotename]], [[ns_dbquotevalue]], [[ns_localsqltimestamp]], [[ns_parsesqldate]], [[ns_parsesqltime]], [[ns_parsesqltimestamp]], [[ns_writecsv]]&lt;br /&gt;
&lt;br /&gt;
== DNS lookup commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_addrbyhost]], [[ns_hostbyaddr]]&lt;br /&gt;
&lt;br /&gt;
== File manipulation commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_chmod]], [[ns_cp]], [[ns_ftruncate]], [[ns_link]], [[ns_mkdir]], [[ns_mktemp]], [[ns_normalizepath]], [[ns_openexcl]], [[ns_purgefiles]], [[ns_rename]], [[ns_rmdir]], [[ns_rollfile]], [[ns_symlink]], [[ns_tmpnam]], [[ns_truncate]], [[ns_unlink]]&lt;br /&gt;
&lt;br /&gt;
== HTML manipulation commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_formvalueput]], [[ns_hrefs]], [[ns_htmlselect]], [[ns_quotehtml]], [[ns_striphtml]], [[ns_tagelement]], [[ns_tagelementset]]&lt;br /&gt;
&lt;br /&gt;
== HTTP commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_http]], [[ns_httpget]], [[ns_httpopen]], [[ns_httppost]]&lt;br /&gt;
&lt;br /&gt;
== Image manipulation commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_gifsize]], [[ns_jpegsize]]&lt;br /&gt;
&lt;br /&gt;
== Internationalization (I18N) support commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_charsets]], [[ns_choosecharset]], [[ns_cookiecharset]], [[ns_encodingforcharset]], [[ns_encodingfortype]], [[ns_formfieldcharset]], [[ns_setformencoding]] / [[ns_urlcharset]]&lt;br /&gt;
&lt;br /&gt;
== Logging commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_accesslog]], [[ns_log]], [[ns_logctl]], [[ns_logroll]]&lt;br /&gt;
&lt;br /&gt;
== Request authorization commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_checkurl]], [[ns_requestauthorize]]&lt;br /&gt;
&lt;br /&gt;
== Request processing commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_register_adp]], [[ns_register_cgi]], [[ns_register_encoding]], [[ns_register_filter_error]], [[ns_register_fastpath]], [[ns_register_filter]], [[ns_register_filter_shortcut]] [[ns_register_proc]], [[ns_register_trace]], [[ns_unregister_adp]], [[ns_unregister_proc]]&lt;br /&gt;
&lt;br /&gt;
== Scheduling commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_after]], [[ns_atclose]], [[ns_atexit]], [[ns_atshutdown]], [[ns_atsignal]], [[ns_cancel]], [[ns_pause]], [[ns_resume]], [[ns_schedule_proc]], [[ns_schedule_daily]], [[ns_schedule_weekly]], [[ns_shutdown]], [[ns_unschedule_proc]]&lt;br /&gt;
&lt;br /&gt;
== Server configuration commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_config]], [[ns_configsection]], [[ns_configsections]], [[ns_library]], [[ns_limits]], [[ns_modulepath]], [[ns_param]], [[ns_pools]], [[ns_section]]&lt;br /&gt;
&lt;br /&gt;
== Server introspection commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_driver]], [[ns_env]], [[ns_info]], [[ns_server]], [[ns_stats]] (3.x only, defunct in 4.0+)&lt;br /&gt;
&lt;br /&gt;
== Socket I/O commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_sock]], [[ns_sockaccept]], [[ns_sockblocking]], [[ns_sockcallback]], [[ns_sockcheck]], [[ns_sockclose]], [[ns_sockdup]], [[ns_sockerrno]], [[ns_socketpair]], [[ns_sockioctl]], [[ns_socklisten]], [[ns_socklistencallback]], [[ns_socknbclose]], [[ns_socknonblocking]], [[ns_socknread]], [[ns_sockopen]], [[ns_sockpair]], [[ns_sockreadwait]], [[ns_sockselect]], [[ns_socksend]], [[ns_sockstrerror]]&lt;br /&gt;
&lt;br /&gt;
== Tcl channel management commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_chan]], [[ns_cleanupchans]], [[ns_getchannels]]&lt;br /&gt;
&lt;br /&gt;
== Tcl interpreter management commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_cleanup]], [[ns_eval]], [[ns_interp_ctl]] (4.5+) / [[ns_ictl]] (4.0), [[ns_init]], [[ns_loop_ctl]], [[ns_markfordelete]], [[ns_reinit]]&lt;br /&gt;
&lt;br /&gt;
== Time commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_fmttime]], [[ns_gmtime]], [[ns_httptime]], [[ns_localtime]], [[ns_parsehttptime]], [[ns_parsetime]], [[ns_time]]&lt;br /&gt;
   &lt;br /&gt;
== Uncategorized ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_cpfp]], [[ns_crypt]], [[ns_getcsv]], [[ns_geturl]], [[ns_guesstype]], [[ns_isformcached]], [[ns_issmallint]], [[ns_paren]], [[ns_parseheader]], [[ns_parsequery]], [[ns_rand]], [[ns_resetcachedform]], [[ns_sendmail]], [[ns_sleep]], [[ns_sourceproc]], [[ns_url2file]], [[ns_urldecode]], [[ns_urlencode]], [[ns_uudecode]], [[ns_uuencode]], [[ns_zlib]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Documentation&amp;diff=5844</id>
		<title>Documentation</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Documentation&amp;diff=5844"/>
		<updated>2010-06-21T21:37:33Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: /* API documentation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There is an effort underway to update and prepare documentation for AOLserver 4.0.  This wiki will be the canonical source for documentation under revision, which will then get commited to CVS in the doc/ directory in roff format.  From there, HTML will be forward-generated from the roff and made available from http://aolserver.com/docs/.&lt;br /&gt;
&lt;br /&gt;
If there is documentation you feel is not complete, represented accurately, or is entirely omitted, please add it to the appropriate place and make a note of it on the [[Documentation Wishlist]] so that people know that someone wants it.&lt;br /&gt;
&lt;br /&gt;
== API documentation ==&lt;br /&gt;
&lt;br /&gt;
* [[Tcl API]] - [http://aolserver.am.net/downloads/tcl-core.tip download] Komodo Tcl syntax method tip/auto-completion file&lt;br /&gt;
* [[C API]] - [http://aolserver.am.net/cvs/tcl C source for Tcl commands]&lt;br /&gt;
* [[Private C API]]&lt;br /&gt;
&lt;br /&gt;
== General documentation ==&lt;br /&gt;
&lt;br /&gt;
* [[Modules]]&lt;br /&gt;
* [[Languages]]&lt;br /&gt;
* [[Toolkits]]&lt;br /&gt;
* [[Tutorials]]&lt;br /&gt;
* [[Administration]] and Configuration&lt;br /&gt;
&lt;br /&gt;
== Guides ==&lt;br /&gt;
&lt;br /&gt;
* [[AOLserver Tuning, Troubleshooting and Scaling]] by [[Kriston J. Rehberg]].&lt;br /&gt;
* [[Virtual Hosting]] in AOLserver.&lt;br /&gt;
* Using upvar: http://dqd.com/~mayoff/notes/tcl/upvar.html&lt;br /&gt;
* [http://www.fpx.de/fp/Software/tcl-c++/tcl-c++.html Making C++ Loadable Modules Work] in Tcl.&lt;br /&gt;
&lt;br /&gt;
== HOWTOs ==&lt;br /&gt;
&lt;br /&gt;
* [[How to set up PHP under AOLserver]]&lt;br /&gt;
* [[How to set up WiKit under AOLserver]]&lt;br /&gt;
* [http://www.rexx.com/~dkuhlman/aolserver_howto.html Beginner's How-to for AOLserver, PyWX, and PostgreSQL]&lt;br /&gt;
* [[How to build AOLserver on Win32]]&lt;br /&gt;
* [[How to set up Project Liberty (IPL) under AOLserver]]&lt;br /&gt;
* [http://www.manicai.net/comp/how/svn/ How to set up ViewCVS for Subversion under AOLserver]&lt;br /&gt;
* [[How to set up SQL-Ledger to serve from AOLserver]]&lt;br /&gt;
* [[How to generate self-signed SSL certificates]]&lt;br /&gt;
* [[How to configure single server to listen on multiple TCP ports]]&lt;br /&gt;
* [[How to add TWAPI extension under AOLserver]]&lt;br /&gt;
* [[How to start stop AOLserver using Daemontools]]&lt;br /&gt;
&lt;br /&gt;
== Community-supported documentation ==&lt;br /&gt;
&lt;br /&gt;
* Notes describing the differences between ArsDigita [[ad13 vs. 3.5.1]].&lt;br /&gt;
&lt;br /&gt;
* [http://philip.greenspun.com/tcl/ Tcl for Web Nerds] is a book by MIT professors Hal Abelson, Philip Greenspun, and Lydia Sandon which covers Tcl programming with the AOL Server&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_ictl&amp;diff=5843</id>
		<title>Ns ictl</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_ictl&amp;diff=5843"/>
		<updated>2010-06-20T23:30:17Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Man page: http://aolserver.com/docs/tcl/ns_ictl.html&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''NAME'''&lt;br /&gt;
&lt;br /&gt;
: ns_ictl - Manipulate and introspect Tcl interpreter internals&lt;br /&gt;
&lt;br /&gt;
'''SYNOPSIS'''&lt;br /&gt;
&lt;br /&gt;
: '''ns_ictl''' ''option ?arg arg ...?''&lt;br /&gt;
&lt;br /&gt;
'''DESCRIPTION'''&lt;br /&gt;
&lt;br /&gt;
: This command provides access to the internal facilities to control and configure multi-threaded Tcl interpreters in the context of AOLserver virtual servers.  It is normally used in startup initialization scripts to define how new interpreters are initialized when created and to support cleanup and re-initalization between transactions (e.g., HTTP connections).  &lt;br /&gt;
*'''ns_ictl addmodule''' ''module''&lt;br /&gt;
: Add a module to the list of modules to be initialized at startup and returns the new list as the result. This command is not normally required as each module specified in the AOLserver modules config section for the corresponding server (e.g., ''ns/server/server1/modules'') is automatically added to the list.  To be clear, this command simply appens the ''module'' to the list, it doesn't perform any loading of modules.&lt;br /&gt;
*'''ns_ictl cancel''' ''thread''&lt;br /&gt;
: Send an asynchronous interrupt request to the specified thread, cancelling any script currently executing on any AOLserver created interpreter (note the interrupt is not virtual-server specific). This command utilizes the facilities of '''Tcl_AsyncMark''' to mark as ready a callback registered with '''Tcl_AsyncCreate'''. The callback places an &amp;quot;async cancel&amp;quot; error message in the interpreter result and returns '''TCL_ERROR''' to unwind the call stack. The underlying Tcl facility has limitations, e.g., the interrupt will only be noticed when Tcl checks via '''Tcl_AsyncReady''' calls between commands and the interrupt can be caught with a '''catch''' command. See the man page for '''Tcl_AsyncCreate''' for details.  This command will throw an error if the thread doesn't have a tcl interpreter and will otherwise return nothing whether the interpreter is actively running or not.&lt;br /&gt;
*'''ns_ictl cleanup'''&lt;br /&gt;
: This command invokes any callbacks registered during a transaction via the C-level '''Ns_TclRegisterDefer''' routine.  Unlike callbacks registered with the '''ns_ictl trace deallocate''' command or '''Ns_TclRegisterTrace''' routine, these callbacks are executed only once and there is no Tcl-level access to the underlying '''Ns_TclRegisterDefer''' routine.  Currently the only thing that uses this is the C code that releases database handles.  This command is invoked by [[ns_cleanup]] Tcl procedure.&lt;br /&gt;
*'''ns_ictl epoch'''&lt;br /&gt;
: This command returns the unique id for the current duplication script for the virtual server.  The id starts as 0 when the virtual server is created and is incremented each time a new script is saved via the '''ns_ictl save''' command.  &lt;br /&gt;
*'''ns_ictl get'''&lt;br /&gt;
: Return the current duplication script for the virtual server.  This command is useful to view the duplication script created by the initialization script at startup.  &lt;br /&gt;
*'''ns_ictl getmodules'''&lt;br /&gt;
: Return the list of modules to be initialized at startup. This list corresponds to the names of modules specified in the virtual server modules config section, e.g., ''ns/server/server1/modules'' unless additional modules are added via the '''ns_ictl addmodule''' command.  &lt;br /&gt;
*'''ns_ictl gettraces''' ''which''&lt;br /&gt;
: Return the list of traces which will be invoked at the specified time. The ''which'' argument can be one of ''create, delete, allocate, deallocate, getconn'', or ''freeconn''.  The traces are returned in the order in which they will be executed.  Script level traces are returns as strings to evaluate and C-level traces are returned with strings which specify the address of the underlying C procedure and argument.  &lt;br /&gt;
*'''ns_ictl once''' ''key script''&lt;br /&gt;
: Evaluate given script once in the virtual server. The given key is a string name which uniquely identifies the corresponding script. This command is useful in a Tcl package which includes one-time initialization routines, e.g., calls to '''ns_register_proc''' or initialization of shared variables using '''nsv_set''' (see '''EXAMPLES''' below).  &lt;br /&gt;
*'''ns_ictl oncleanup''' ''script''&lt;br /&gt;
: This command is equivalent to '''ns_ictl trace deallocate''' ''script''.  &lt;br /&gt;
*'''ns_ictl oncreate''' ''script''&lt;br /&gt;
: This command is equivalent to '''ns_ictl trace create''' ''script''.  &lt;br /&gt;
*'''ns_ictl ondelete''' ''script''&lt;br /&gt;
: This command is equivalent to '''ns_ictl trace delete''' ''script''.  &lt;br /&gt;
*'''ns_ictl oninit''' ''script''&lt;br /&gt;
: This command is equivalent to '''ns_ictl trace allocate''' ''script''.  &lt;br /&gt;
*'''ns_ictl package require''' ''?-exact? package ?version?''&lt;br /&gt;
: This command is used to require a package in the calling interpreter and, if successfully loaded, it will require the exact same version in all other interpreters for the virtual server. If version consistency is not important, you can achieve the same effect with '''ns_ictl trace allocate''' {package require ''package''}. In addition, allocate too frequent for most packages.  Package state is retained between thread allocations in a given interpreter, so at startup, doing ns_ictl oninit {package require ''package''} should be sufficient and will also work in AOLserver 4.0.  This option can be useful, however, if you want to alter the state of already created interpreters at runtime.&lt;br /&gt;
*'''ns_ictl runtraces''' which''&lt;br /&gt;
: This command runs the requested traces. The ''which'' argument must be one of '''create''', '''delete''', '''allocate''', '''deallocate''', '''getconn''', or '''freeconn'''.  Direct calls to this command are not normally necessary as the underlying C code will invoke the callbacks at the required times.  Exceptions include calling '''ns_ictl runtraces''' or testing purposes or to mimic the normal cleanup and initialization work performed on between transactions in a long running thread (see '''EXAMPLES''' below).  &lt;br /&gt;
*'''ns_ictl save''' ''script''&lt;br /&gt;
: Save the given script as the duplication script, incrementing the virtual server epoch number.  This command is normally called by the bootstrap script after constructing the script to duplicate the procedures defined by sourcing the various module initialization script files.  It's also used by [[ns_eval]] to dynamically update the interpreter 'template'.&lt;br /&gt;
*'''ns_ictl threads'''&lt;br /&gt;
: Return a list of all threads with interpreters in this processs. The ids return are small strings which represent the underlying thread ids and can be passed to the '''ns_ictl cancel''' command to send an asynchronous cancel request.  Note that the list will include currently idle threads as long as at some point they had allocated an interpreter.&lt;br /&gt;
*'''ns_ictl trace create''' ''script''&lt;br /&gt;
: Register ''script'' to be called when an interpreter is first created. This is useful to create procedures, require packages, or initialize other state to be used during the lifetime of the interpreter.  &lt;br /&gt;
*'''ns_ictl trace delete''' ''script''&lt;br /&gt;
: Register ''script'' to be called before an interpreter is destroyed. This is useful to free any resources which may have been allocated for the interpreter during the lifetime of the interpreter.  &lt;br /&gt;
*'''ns_ictl trace allocate''' ''script''&lt;br /&gt;
: Register ''script'' to be called each time an interpreter is allocated for use by the '''Ns_TclAllocateInterp''' routine. This is useful for reinitializing resources which may be used during a single transaction in the interpreter.  &lt;br /&gt;
*'''ns_ictl trace deallocate''' ''script''&lt;br /&gt;
: Register ''script'' to be called each time an interpreter is returned after a transaction with the '''Ns_TclDeAllocateInterp''' routine. This is useful for garbage collection, i.e., freeing any resources which may be used during a single transaction in the interpreter.  &lt;br /&gt;
*'''ns_ictl trace getconn''' ''script''&lt;br /&gt;
: Register ''script'' to be called each time an interpreter is returned and associated with an HTTP connection with the '''Ns_GetConnInterp''' routine. This could be useful to define variables relative to the HTTP request.  &lt;br /&gt;
*'''ns_ictl trace freeconn''' ''script''&lt;br /&gt;
: Register ''script'' to be called each time an HTTP connection is closed. This could be used to log information about the request, e.g., timing statistics.  Note that the interpreter may still be actively evaluating a script after the connection is closed, i.e., this is not equivalent to '''ns_ictl trace deallocate''' for connection-related interpreters.  &lt;br /&gt;
*'''ns_ictl update'''&lt;br /&gt;
: This command can be used to atomically compare the epoch of the current duplication script with the epoch of the interpreter, evaluating the script and updating the epoch in the interpreter if they do not match.  This command is generally registered as a callback with '''ns_ictl trace allocate''' by the initialization code.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''INTERPRETER ALLOCATION'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: Tcl interpreter in AOLserver are available on demand with state specific to a virtual server.  These interpreters are also expected to be reused for multiple transactions (e.g., HTTP connections, scheduled procedures, socket callbacks).  &lt;br /&gt;
: To support reuse, AOLserver provides the C-level '''Ns_TclAllocateInterp''' routine to allocate an interpreter from a per-thread cache (creating and initializing a new interpreter if necessary) and the '''Ns_TclDeAllocateInterp''' routine to return an interpreter to the cache when no longer required.  All interpreters in the per-thread cache are destroyed when a thread exists.  &lt;br /&gt;
: In general, only C-level extension writers need to call the C-level API's directly; the various Tcl-level interfaces in AOLserver (e.g., '''ADP''' pages, '''ns_regiseter_proc''', '''ns_schedule_proc''', '''ns_thread''', etc.) allocate and reuse interpreters using the C-level API's automatically before invoking the cooresponding script or ADP page.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''INTERPRETER TRACES'''&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
: To ensure a consistent state of interpreters when allocated and enable cleanup and reinitialization between transactions, each virtual server maintains a list of callbacks to be invoked at various points in the lifetime of an interpreter.  These callbacks are generally installed when the server is initialized at startup and then called automatically by the '''Ns_TclAllocateInterp''' and '''Ns_TclDeAllocateInterp''' API's at the appropriate times and in consistent order.  The '''Ns_TclRegisterTrace''' routine can be used to register C-level callbacks and the '''ns_ictl trace''' command can be used to register Tcl script callbacks.  The '''ns_ictl gettraces''' command can be used to list all currently registered callbacks, both at the Tcl script and C level.  &lt;br /&gt;
: Callbacks registered via the tracing facility are invoked in a specific order depending on the type.  Initialization style callbacks including '''create''', '''allocate''', and '''getconn''' are invoked in FIFO order, with all script callbacks invoked after all C-level callbacks.  This enables extension writers to utilize the facilities of previously initialized extensions. Correspondingly, cleanup style callbacks including '''freeconn''', '''deallocate''', and '''delete''' are invoked in LIFO order, with all scripts callbacks invoked before C-level callbacks. This helps avoid the possibility that a cleanup callback utilizes features of a previously cleaned up extension.  &lt;br /&gt;
: In addition, the '''ns_ictl package''' command can be used to consistently manage the loading of a Tcl package in all interpreters for a virtual server. This feature is mostly a convenience routine built above the generic trace framework with additional checks to ensure version number consistency.  Coupled with '''ns_ictl once''', the '''ns_ictl package''' command provides a clean framework to utilize Tcl packages in multi-threaded AOLserver (see '''EXAMPLES''').  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''VIRTUAL SERVER TCL INITIALIZATION'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: AOLserver also supports a Tcl initialization framework for virtual servers based on callbacks registered by loadable modules and the sourcing of scripts files located in corresponding directories. Options to '''ns_ictl''' to support this framework include ''save'', ''get'', ''epoch'', and ''update'' and are used in conjunction with the generic tracing facility by the virtual server bootstrap script (normally ''bin/init.tcl''). The '''ns_eval''' command also relies on this framework to support dynamic update of the state of interpreters.  &lt;br /&gt;
: This initialization framework pre-dates the Tcl package facilities and utilizes introspection of the state of a startup interpreter at the end of initialization to construct a single script which attempts to duplicate the state in subsequent interpreters.  Steps taken during this initialization include:  &lt;br /&gt;
*1.  Load all modules in the server's module config section, e.g.,&lt;br /&gt;
: ''ns/server/server1/modules''.  Modules with Tcl C-level extensions typically call the legacy '''Ns_TclInitInterps''' routine or the more general '''Ns_TclRegisterTrace''' routine with the ''NS_TCL_TRACE_CREATE'' flag in their module init routine to register a callback to invoke when new interpreters are created. The callback normally creates one or more new commands in the interpreter with '''Tcl_CreateObjCommand''' but may perform any per-interpreter initialization required, e.g., creating and saving private state with the '''Tcl_SetAssocData''' facility.  In addition, as modules are loaded, the string name of the module is added to the list of known modules.  &lt;br /&gt;
*2.  After all C modules are loaded, AOLserver creates a new Tcl&lt;br /&gt;
: interpreter for the virtual server, executing any trace callbacks already registered via the loaded C modules (e.g., any '''Ns_TclInitInterps''' callbacks) and then sources the virtual server bootstrap script, normally ''bin/init.tcl''.  This script creates a few utility procedures and then sources all ''private'' and ''public'' script files in directories which correspond to loaded modules in the order in which they were loaded.  These directories are normally relative to the virtual server and to the AOLserver installation directory, e.g., initialization script files for the module ''mymod'' in the ''server1'' virtual server would be searched for in the ''servers/server1/modules/tcl/mymod/'' and ''modules/tcl/mymod/''.  Any ''init.tcl'' file found in each directory is sourced first with all remaining files sourced in alphabetical order. In addition, any files in the ''public'' directory with identical names to files in the private directory are skipped as a means to enable overloading of specific functionality on a per-server basis.  In practice, most modules only contain shared utility procedures defined in the ''public'' directories and the ''private'' directories are empty or non-existant. The script files normally contain a mix of commands to evaluate once for server configuration (e.g., a call to '''ns_register_proc''' to bind a Tcl procedure to an HTTP request URL) with '''proc''' and '''namespace''' commands to provide additional functionality in the interpreter.  &lt;br /&gt;
*3.  After all script files have been sourced, the bootstrap script&lt;br /&gt;
: code then uses a collection of recursive procedures to extract the definitions of all procedures defined in all namespaces.  The definitions are used to construct a script which attempts to duplicate the state of the initialization interpreters.  This scripts is then saved as the per-virtual server duplication script with the '''ns_ictl save''' command which also increments the ''epoch'' to 1.  There are limits to this approach to determine the full state, e.g., it does not attempt to duplicate any global variables which may have been defined in the startup scripts. Typically, startup scripts will use '''nsv_set''' or other mechanisms to store such shared state.  &lt;br /&gt;
*4.  The bootstrap code then uses the '''ns_ictl trace allocate'''&lt;br /&gt;
: command to register a callback to the '''ns_ictl update''' command each time an interpreter is allocated for use.  In practice, interpreters are created with the default ''epoch'' of 0 and the first call to '''ns_ictl update''' determines an out-of-date condition, evaluates the duplication script, and increments the interpreter's ''epoch'' to 1 to match the state created by the startup interp.  &lt;br /&gt;
*5.  Subsequent calls the '''ns_eval''', if any, will evaluate the&lt;br /&gt;
: given script and then re-generate and save the duplication script as was done at startup, incrementing the ''epoch'' once again. In this way, dynamic updates which are detected in other interpreters on their next call to '''ns_ictl update''' can be supported in a limited fashion.  &lt;br /&gt;
: In practice, while generally successful, this duplication technique has inhibited the clean use of proper Tcl package extensions and encouraged the use of the '''ns_eval''' command which is generally not recommended for the non-deterministic manner in which it attempts to dynamically reconfigure a server.  Also, commands required to configure the server once (e.g., calls to '''ns_register_proc''') are inter-mixed with '''proc''' commands designed to extend functionality in all interpreters, complicating configuration management.  &lt;br /&gt;
: As an alternative, the example below illustrates a means to more explicitly manage configuration through a combination of direct calls to '''ns_ictl trace create''' and '''ns_ictl once'''. Unfortunately, the all encompassing nature of the legacy initialization approach makes it difficult to incrementally move to this cleaner approach because the duplication script construction code is unable to distinguish between state created with the newer, cleaner '''ns_ictl''' commands and state created as a side effect of one or more script files being sourced.  As such, it is expected the legacy initialization framework will remain in place until AOLserver 5.x when it will be removed entirely in a non-backwards compatible move towards the cleaner API's.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''EXAMPLES'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: This example illustrates the use of '''ns_ictl package''' and '''ns_ictl once''' to load an AOLserver-aware Tcl package into a virtual server.  The following code could be added to the virtual server bootstrap script, ''bin/init.tcl'', to load ''MyPkg'' in the virtual server:  &lt;br /&gt;
: &lt;br /&gt;
    &amp;lt;pre&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    #&lt;br /&gt;
    # Startup code in bin/init.tcl:&lt;br /&gt;
    #&lt;br /&gt;
    # Load MyPkg in all interps (including this one).&lt;br /&gt;
    #&lt;br /&gt;
    ns_ictl package require MyPkg&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;/pre&amp;gt;  &lt;br /&gt;
: This call will result in the package being loaded into the startup interpreter in the ordinary Tcl fashion (see the '''package''' man page for details).  Ordinary Tcl extension packages would need no modifications but packages which utilize AOLserver-specific features or require garbage collection between transactions could also use '''ns_ictl''' for finer grained control. For example, the ''init.tcl'' script specified by the '''package ifneeded''' command in the ''MyPkg'' package's ''pkgIndex.tcl'' file could contains:  &lt;br /&gt;
: &lt;br /&gt;
    &amp;lt;pre&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    #&lt;br /&gt;
    # Package code in lib/myPkg1.0/init.tcl:&lt;br /&gt;
    #&lt;br /&gt;
    #&lt;br /&gt;
    &lt;br /&gt;
    package provide MyPkg 1.0&lt;br /&gt;
    &lt;br /&gt;
    #&lt;br /&gt;
    # Server init which will be executed the first time called,&lt;br /&gt;
    # normally in the context of the startup interpreter as above.&lt;br /&gt;
    #&lt;br /&gt;
    &lt;br /&gt;
    ns_ictl once MyPkg {&lt;br /&gt;
        # Register the run Tcl proc HTTP handler.&lt;br /&gt;
        ns_register_proc /mypkg mkpkg::run&lt;br /&gt;
        # Register a garbage collection callback.&lt;br /&gt;
        ns_ictl trace deallocate mypkg::cleanup&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    #&lt;br /&gt;
    # Code which will be invoked to initialize the package in&lt;br /&gt;
    # all interpreters when required.&lt;br /&gt;
    #&lt;br /&gt;
    proc mypkg::run {} {&lt;br /&gt;
        ... handle /mypkg requests ...&lt;br /&gt;
    }&lt;br /&gt;
    proc mkpkg::cleanup {} {&lt;br /&gt;
        ... cleanup transaction resources for mypkg, e.g., db handles ...&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;/pre&amp;gt;  &lt;br /&gt;
: Other examples:&lt;br /&gt;
    % ns_ictl epoch&lt;br /&gt;
    1&lt;br /&gt;
&lt;br /&gt;
    % ns_ictl getmodules&lt;br /&gt;
    nsdb nslog nscp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''SEE ALSO'''&lt;br /&gt;
&lt;br /&gt;
: [[ns_cleanup]], [[ns_init]], [[ns_eval]], [[ns_markfordelete]]&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]] - [[Category:Core Tcl API]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_filter&amp;diff=5842</id>
		<title>Ns register filter</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_filter&amp;diff=5842"/>
		<updated>2010-06-20T22:12:30Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{manpage|ns_filter}}&lt;br /&gt;
&lt;br /&gt;
'''NAME'''&lt;br /&gt;
&lt;br /&gt;
ns_register_filter - Register a filter or trace callback&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''SYNOPSIS'''&lt;br /&gt;
&lt;br /&gt;
'''ns_register_filter''' ''?-first? when method URLpatttern procname ?arg arg ...?''&lt;br /&gt;
&lt;br /&gt;
'''ns_register_filter_shortcut''' ''when method URLpatttern'' (new in AOLserver 4.5.2)&lt;br /&gt;
&lt;br /&gt;
'''ns_register_filter_error''' ''?-first? when method URLpatttern'' ([http://aolserver.am.net/code/modules/ampools.adpx ampools] module for AOLserver 4.5.2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''DESCRIPTION'''&lt;br /&gt;
&lt;br /&gt;
: Registers a Tcl filter script for the specified method/URL combination on a virtual server. The script can be called at one of several times as indicated by the ''when'' argument:&lt;br /&gt;
:* '''read''' - upcoming in AOLserver 4.6 - runs in the driver thread while in the ''read'' state in a ''different'' Tcl interpreter from the rest of the connection - procedure will not receive a conn id so should not have arguments(?) and normal [[ns_conn]] and similar commands will not work.&lt;br /&gt;
:* '''prequeue''' - runs in the driver thread while in the ''ready'' state in a ''different'' Tcl interpreter from the rest of the connection - new in AOLserver 4.5 but there are known memory leak issues that are fixed in upcoming AOLserver 4.6. Procedure will not receive a conn id so should not have arguments(?) and normal [[ns_conn]] and similar commands will not work.&lt;br /&gt;
:* '''preauth''' - pre-authorization&lt;br /&gt;
:* '''postauth'''- post-authorization before page data has been returned to the user&lt;br /&gt;
:* '''write''' - upcoming in AOLserver 4.6 - Invokes proc after each write to the client.  Server normally buffers response output so this callback is called potentially just once when flushing the connection output buffers.&lt;br /&gt;
:* '''trace''' - after the connection has been processed and closed.&lt;br /&gt;
&lt;br /&gt;
: The registered script will be called at the specified stage of a connection, if the method/URL combination for the filter matches the method/URL combination for the connection using glob style (i.e. as in string match) matching. For example, these are valid ''URLpatterns'':&lt;br /&gt;
&lt;br /&gt;
    /employees/*.tcl&lt;br /&gt;
    /accounts/*/out&lt;br /&gt;
&lt;br /&gt;
: Using pre-authorization, the procedure will be called (assuming that the method/URL combination matches) just before authorization. If the procedure returns with a code of:&lt;br /&gt;
&lt;br /&gt;
:* '''TCL_OK'''  (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next pre-authorization filter for this connection, or, if there are no more pre-authorization filters, it will continue on with authorization.&lt;br /&gt;
:* '''TCL_BREAK''' (using: return &amp;quot;filter_break&amp;quot;): The server will not process any more pre-authorization filters for this connection, and it will continue on with authorization.&lt;br /&gt;
:* '''TCL_RETURN''' (using: return &amp;quot;filter_return&amp;quot;): The server will close the connection and will not run any more pre-authorization filters. It will not authorize the request, and it will not run the function registered for this METHOD/URL. It WILL run any trace functions registered for this METHOD/URL, usually including logging. It is assumed that the filter has sent a proper response (e.g., using ns_return) to the client before returning TCL_RETURN.&lt;br /&gt;
&lt;br /&gt;
: Using post-authorization, the procedure will be called (assuming that the method/URL combination matches) just after successful authorization. If the procedure returns:&lt;br /&gt;
:* '''TCL_OK''' (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next post-authorization filter for this connection, or, if there are no more post-authorization filters, it will run the function registered to handle this request.&lt;br /&gt;
:* '''TCL_BREAK''' (using: return &amp;quot;filter_break&amp;quot;): The server will not process any more post-authorization filters for this connection, and it will run the function registered to handle this request.&lt;br /&gt;
:* '''TCL_RETURN''' (using: return &amp;quot;filter_return&amp;quot;): The server will close the connection and will not run any more post-authorization filters and it will not run the function registered for this METHOD/URL. It WILL run any trace functions registered for this METHOD/URL, usually including logging. It is assumed that the filter has returned a proper response (e.g., using ns_return) to the client before returning TCL_RETURN.&lt;br /&gt;
&lt;br /&gt;
: Using trace, the procedure will be called (assuming that the method/URL combination match) after the connection has been totally processed and closed. If the procedure returns:&lt;br /&gt;
:* '''TCL_OK''' (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next trace filter.&lt;br /&gt;
:* '''TCL_BREAK''' (using: return &amp;quot;filter_break&amp;quot;): The rest of the trace filters are ignored.&lt;br /&gt;
:* '''TCL_RETURN''' (using: return &amp;quot;filter_break&amp;quot;): The rest of the trace filters are ignored.&lt;br /&gt;
&lt;br /&gt;
'''Syntax for the registered procedure:'''&lt;br /&gt;
&lt;br /&gt;
: The ''conn'' (connection id) argument is optional for procedures registered by ns_register_filter if the procedure has 1 or 2 arguments (including why but not including ''conn''). The following examples show the variations that can be used in this case:&lt;br /&gt;
&lt;br /&gt;
    '''ns_register_filter''' ''trace'' GET /noargs filter_noargs&lt;br /&gt;
    '''ns_register_filter''' ''trace'' GET /context filter_context fnord&lt;br /&gt;
    '''ns_register_filter''' ''trace'' GET /conncontext filter_conncontext&lt;br /&gt;
&lt;br /&gt;
    proc filter_noargs { why } {&lt;br /&gt;
    ns_log Notice &amp;quot;filter noargs&amp;quot;&lt;br /&gt;
    return filter_ok&lt;br /&gt;
    } ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
    proc filter_context { arg why } {&lt;br /&gt;
    ns_log Notice &amp;quot;filter context. Arg: $arg&amp;quot;&lt;br /&gt;
    return filter_ok&lt;br /&gt;
    } ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
    proc filter_conncontext { conn arg why } {&lt;br /&gt;
    ns_log Notice &amp;quot;filter conn context&amp;quot;&lt;br /&gt;
    return filter_ok&lt;br /&gt;
    } ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
: The ''conn'' (connection) argument is required for procedures registered by '''ns_register_filter''' if the procedure has 3 or more arguments (including why but not including ''conn''). The ''conn'' argument is automatically filled with the connection id. The first argument following ''conn'' will always take the value supplied by '''ns_register_filter''', if there is one, or an empty value. The why argument at the end is automatically filled with the type of filter requested (the ''when'' it was registered for). All other arguments must supply a default value. The following examples show the variations that can be used in this case:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;&lt;br /&gt;
    '''ns_register_filter''' ''postauth'' GET /threeargs threeargs aaa&lt;br /&gt;
    '''ns_register_filter''' ''postauth'' GET /fourargs fourargs aaa bbb ccc&lt;br /&gt;
    &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    proc threeargs { conn context { greeble bork } why } {&lt;br /&gt;
    ...&lt;br /&gt;
    } ;&lt;br /&gt;
&lt;br /&gt;
    proc fourargs { conn context { greeble bork } {hoover quark} why } {&lt;br /&gt;
    ...&lt;br /&gt;
    } ;&lt;br /&gt;
&lt;br /&gt;
: When a GET of /threeargs is requested, the conn and why arguments will be filled automatically, the context argument will be assigned &amp;quot;aaa&amp;quot; and the greeble argument will be assigned the default value &amp;quot;bork&amp;quot;. When a GET of /fourargs is requested, the conn and why arguments will be filled automatically, the context argument will be assigned &amp;quot;aaa&amp;quot;, the greeble argument will be assigned &amp;quot;bbb&amp;quot;, and the hoover argument will be assigned the default value &amp;quot;quark&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
:  Note that the server detects the number of arguments in your procedure only the first time it is invoked as a filter/trace.  Therefore if you change the number of arguments after this, this change will not be recognized until after a server restart.&lt;br /&gt;
&lt;br /&gt;
=== '''ns_register_filter_shortcut''' ===&lt;br /&gt;
: Registers a C filter at the specified ''when'' at the top of the filters list which simply returns '''NS_FILTER_RETURN''', effectively preventing further filter processing for that ''when''.  This is most useful to prevent a Tcl interpreter from being allocated to run globally registered filters for Fastpath (static) resources that don't really need that filter.  In combination with [[ns_pools]], this allows you to keep threads dedicated to serving requests for URLs registered to a particular pool lightweight, without the memory overhead of a Tcl interpreter.&lt;br /&gt;
&lt;br /&gt;
=== '''ns_register_filter_error''' ===&lt;br /&gt;
: Similarly, registers a C filter at the specified ''when'' (but not at the top, unless ''-first'' is specified) which simply returns '''NS_ERROR'''.  This is most useful with the '''trace''' ''when'' to prevent void traces (registered with [[ns_register_trace]]) and ServerTraces, i.e. access logging.&lt;br /&gt;
&lt;br /&gt;
'''NOTES'''&lt;br /&gt;
&lt;br /&gt;
: Note '''ns_register_filter''' (and _trace) is similar to '''[[ns_register_proc]]''' except that the pattern-matching for the URL is performed differently. With '''ns_register_proc''', the specified URL is used to match that URL and any URL below it in the hierarchy. Wildcards such as &amp;quot;*&amp;quot; are meaningful only for the final part of the URL, such as /scripts/*.tcl. With '''ns_register_filter''', the ''URLpattern'' is used to match URLs as a string with standard string-matching characters. '''ns_register_proc''' always results in a single match to just one procedure, whereas multiple procedures registered with '''ns_register_filter''' can be matched and will be called in the order they were registered.&lt;br /&gt;
&lt;br /&gt;
: In AOLserver 4.5.2, you can use the optional ''-first'' switch to specify that the procedure should go to the top of registered filters for a particular pattern and therefore to be called first.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: To be more precise the allowed matching characters in ''URLpattern'' are determined by [http://www.tcl.tk/man/tcl8.0/TclLib/StrMatch.htm Tcl_StrMatch] which in turn is determined by [http://www.tcl.tk/man/tcl8.0/TclCmd/string.htm#M10 TCL string match].&lt;br /&gt;
&lt;br /&gt;
'''SEE ALSO'''&lt;br /&gt;
&lt;br /&gt;
: '''[[ns_register_trace]]''' - very similar to '''ns_register_filter trace''' - known internally as ''void_traces'', procedures registered by this command fire after the procedures registered by '''ns_register_filter trace''' and differ in that they only execute if a response was successfully sent to the client (i.e. not a Server Error), plus their return value is ignored.  See '''[[ns_register_trace]]''' for more details.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[[Category:Core Tcl API]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_filter_error&amp;diff=5841</id>
		<title>Ns register filter error</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_filter_error&amp;diff=5841"/>
		<updated>2010-06-20T21:57:42Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''ns_register_filter_error''' ''?-first? when method URLpatttern'' (from [http://aolserver.am.net/code/modules/ampools.adpx ampools] module for AOLserver 4.5.2) - see [[ns_register_filter]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_filter_shortcut&amp;diff=5840</id>
		<title>Ns register filter shortcut</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_filter_shortcut&amp;diff=5840"/>
		<updated>2010-06-20T21:57:01Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: Created page with ''''ns_register_filter_shortcut''' ''when method URLpatttern'' (new in AOLserver 4.5.2 - from [http://sourceforge.net/tracker/?func=detail&amp;amp;aid=1012103&amp;amp;group_id=3152&amp;amp;atid=353152 RF…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''ns_register_filter_shortcut''' ''when method URLpatttern'' (new in AOLserver 4.5.2 - from [http://sourceforge.net/tracker/?func=detail&amp;amp;aid=1012103&amp;amp;group_id=3152&amp;amp;atid=353152 RFE 1012103]) - see [[ns_register_filter]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_filter_error&amp;diff=5839</id>
		<title>Ns register filter error</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_filter_error&amp;diff=5839"/>
		<updated>2010-06-20T21:52:25Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''ns_register_filter_error''' ?-first? when method URLpatttern (from [http://aolserver.am.net/code/modules/ampools.adpx ampools] module for AOLserver 4.5.2) - see [[ns_register_filter]] for more details&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_filter_error&amp;diff=5838</id>
		<title>Ns register filter error</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_filter_error&amp;diff=5838"/>
		<updated>2010-06-20T21:50:51Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: Created page with 'ns_register_filter_error ?-first? when method URLpatttern (from ampools module for AOLserver 4.5.2) - see ns_register_filter for more details'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;ns_register_filter_error ?-first? when method URLpatttern (from ampools module for AOLserver 4.5.2) - see [[ns_register_filter]] for more details&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Tcl_API&amp;diff=5837</id>
		<title>Tcl API</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Tcl_API&amp;diff=5837"/>
		<updated>2010-06-20T17:34:52Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: /* Request processing commands */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Links to all of the Tcl commands provided by the AOLserver core &amp;quot;out of the box&amp;quot;.  To view a complete list of these commands in alphabetical order, try the [[:Category:Core Tcl API]] page.&lt;br /&gt;
&lt;br /&gt;
Like what you see here?  Want to try your hand at documenting a command, too?  Here's [[how to document the core Tcl API]].&lt;br /&gt;
&lt;br /&gt;
== ADP, Request and Response-oriented commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_adp_abort]], [[ns_adp_append]], [[ns_adp_argc]], [[ns_adp_argv]], [[ns_adp_bind_args]], [[ns_adp_break]], [[ns_adp_close]], [[ns_adp_ctl]], [[ns_adp_debug]], [[ns_adp_debuginit]], [[ns_adp_dir]], [[ns_adp_dump]], [[ns_adp_eval]], [[ns_adp_exception]], [[ns_adp_flush]], [[ns_adp_include]], [[ns_adp_mime]], [[ns_adp_mimetype]], [[ns_adp_parse]], [[ns_adp_puts]] ([[ns_puts]]), [[ns_adp_return]], [[ns_adp_safeeval]], [[ns_adp_stats]], [[ns_adp_stream]], [[ns_adp_tell]], [[ns_adp_trunc]]&lt;br /&gt;
&lt;br /&gt;
:'''Registered (fka fancy) ADP tags:'''&lt;br /&gt;
:[[ns_adp_registeradp]] (same as deprecated [[ns_adp_registertag]])&lt;br /&gt;
:[[ns_adp_registerproc]]&lt;br /&gt;
:[[ns_adp_registerscript]] (same as deprecated [[ns_register_adptag]]) &lt;br /&gt;
&lt;br /&gt;
:'''Request information and received content''':&lt;br /&gt;
: [[ns_conn]], [[ns_conncptofp]] (same as deprecated [[ns_writecontent]])&lt;br /&gt;
: [[ns_getform]], [[ns_getformfile]]&lt;br /&gt;
: [[ns_queryexists]], [[ns_queryget]], [[ns_querygetall]]&lt;br /&gt;
: [[ns_browsermatch]]&lt;br /&gt;
&lt;br /&gt;
:'''Standard response commands:'''&lt;br /&gt;
: [[ns_return]], [[ns_returnadminnotice]], [[ns_returnbadrequest]], [[ns_returnerror]], [[ns_returnfile]], [[ns_returnforbidden]], [[ns_returnfp]], [[ns_returnmoved]], [[ns_returnnotfound]], [[ns_returnnotice]], [[ns_returnok]], [[ns_returnredirect]], [[ns_returnunauthorized]]&lt;br /&gt;
&lt;br /&gt;
:'''More control over response:'''&lt;br /&gt;
: [[ns_setexpires]], [[ns_updateheader]], [[ns_respond]]&lt;br /&gt;
&lt;br /&gt;
:'''Manual response:'''&lt;br /&gt;
: [[ns_headers]], [[ns_startcontent]], [[ns_write]], [[ns_writefp]] / [[ns_connsendfp]] (deprecated)&lt;br /&gt;
&lt;br /&gt;
== Cache commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_cache]], [[ns_cache_flush]], [[ns_cache_keys]], [[ns_cache_names]], [[ns_cache_size]], [[ns_cache_stats]]&lt;br /&gt;
&lt;br /&gt;
== Concurrent programming commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_cond]], [[ns_critsec]], [[ns_event]], [[ns_job]], [[ns_kill]], [[ns_mutex]], [[ns_sema]], [[ns_thread]]&lt;br /&gt;
&lt;br /&gt;
== Custom data structures and variable manipulation commands ==&lt;br /&gt;
* TclX keyed lists:&lt;br /&gt;
&lt;br /&gt;
: [[keyldel]], [[keylget]], [[keylkeys]], [[keylset]]&lt;br /&gt;
* [[Thread-shared Variables]] (NSVs):&lt;br /&gt;
&lt;br /&gt;
: [[nsv_get]], [[nsv_exists]], [[nsv_set]], [[nsv_incr]], [[nsv_append]], [[nsv_lappend]], [[nsv_array]], [[nsv_unset]], [[nsv_names]]&lt;br /&gt;
* Sets and multisets:&lt;br /&gt;
&lt;br /&gt;
: [[ns_findset]], [[ns_set]]&lt;br /&gt;
* ???&lt;br /&gt;
&lt;br /&gt;
: [[ns_share]], [[ns_var]]&lt;br /&gt;
&lt;br /&gt;
== Database commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_buildsqldate]], [[ns_buildsqltime]], [[ns_buildsqltimestamp]], [[ns_db]], [[ns_dbquotename]], [[ns_dbquotevalue]], [[ns_localsqltimestamp]], [[ns_parsesqldate]], [[ns_parsesqltime]], [[ns_parsesqltimestamp]], [[ns_writecsv]]&lt;br /&gt;
&lt;br /&gt;
== DNS lookup commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_addrbyhost]], [[ns_hostbyaddr]]&lt;br /&gt;
&lt;br /&gt;
== File manipulation commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_chmod]], [[ns_cp]], [[ns_ftruncate]], [[ns_link]], [[ns_mkdir]], [[ns_mktemp]], [[ns_normalizepath]], [[ns_openexcl]], [[ns_purgefiles]], [[ns_rename]], [[ns_rmdir]], [[ns_rollfile]], [[ns_symlink]], [[ns_tmpnam]], [[ns_truncate]], [[ns_unlink]]&lt;br /&gt;
&lt;br /&gt;
== HTML manipulation commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_formvalueput]], [[ns_hrefs]], [[ns_htmlselect]], [[ns_quotehtml]], [[ns_striphtml]], [[ns_tagelement]], [[ns_tagelementset]]&lt;br /&gt;
&lt;br /&gt;
== HTTP commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_http]], [[ns_httpget]], [[ns_httpopen]], [[ns_httppost]]&lt;br /&gt;
&lt;br /&gt;
== Image manipulation commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_gifsize]], [[ns_jpegsize]]&lt;br /&gt;
&lt;br /&gt;
== Internationalization (I18N) support commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_charsets]], [[ns_choosecharset]], [[ns_cookiecharset]], [[ns_encodingforcharset]], [[ns_encodingfortype]], [[ns_formfieldcharset]], [[ns_setformencoding]] / [[ns_urlcharset]]&lt;br /&gt;
&lt;br /&gt;
== Logging commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_accesslog]], [[ns_log]], [[ns_logctl]], [[ns_logroll]]&lt;br /&gt;
&lt;br /&gt;
== Request authorization commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_checkurl]], [[ns_requestauthorize]]&lt;br /&gt;
&lt;br /&gt;
== Request processing commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_register_adp]], [[ns_register_cgi]], [[ns_register_encoding]], [[ns_register_filter_error]], [[ns_register_fastpath]], [[ns_register_filter]], [[ns_register_filter_shortcut]] [[ns_register_proc]], [[ns_register_trace]], [[ns_unregister_adp]], [[ns_unregister_proc]]&lt;br /&gt;
&lt;br /&gt;
== Scheduling commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_after]], [[ns_atclose]], [[ns_atexit]], [[ns_atshutdown]], [[ns_atsignal]], [[ns_cancel]], [[ns_pause]], [[ns_resume]], [[ns_schedule_proc]], [[ns_schedule_daily]], [[ns_schedule_weekly]], [[ns_shutdown]], [[ns_unschedule_proc]]&lt;br /&gt;
&lt;br /&gt;
== Server configuration commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_config]], [[ns_configsection]], [[ns_configsections]], [[ns_library]], [[ns_limits]], [[ns_modulepath]], [[ns_param]], [[ns_pools]], [[ns_section]]&lt;br /&gt;
&lt;br /&gt;
== Server introspection commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_driver]], [[ns_env]], [[ns_info]], [[ns_server]], [[ns_stats]] (3.x only, defunct in 4.0+)&lt;br /&gt;
&lt;br /&gt;
== Socket I/O commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_sock]], [[ns_sockaccept]], [[ns_sockblocking]], [[ns_sockcallback]], [[ns_sockcheck]], [[ns_sockclose]], [[ns_sockdup]], [[ns_sockerrno]], [[ns_socketpair]], [[ns_sockioctl]], [[ns_socklisten]], [[ns_socklistencallback]], [[ns_socknbclose]], [[ns_socknonblocking]], [[ns_socknread]], [[ns_sockopen]], [[ns_sockpair]], [[ns_sockreadwait]], [[ns_sockselect]], [[ns_socksend]], [[ns_sockstrerror]]&lt;br /&gt;
&lt;br /&gt;
== Tcl channel management commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_chan]], [[ns_cleanupchans]], [[ns_getchannels]]&lt;br /&gt;
&lt;br /&gt;
== Tcl interpreter management commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_cleanup]], [[ns_eval]], [[ns_interp_ctl]] (4.5+) / [[ns_ictl]] (4.0), [[ns_init]], [[ns_loop_ctl]], [[ns_markfordelete]], [[ns_reinit]]&lt;br /&gt;
&lt;br /&gt;
== Time commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_fmttime]], [[ns_gmtime]], [[ns_httptime]], [[ns_localtime]], [[ns_parsehttptime]], [[ns_parsetime]], [[ns_time]]&lt;br /&gt;
   &lt;br /&gt;
== Uncategorized ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_cpfp]], [[ns_crypt]], [[ns_getcsv]], [[ns_geturl]], [[ns_guesstype]], [[ns_isformcached]], [[ns_issmallint]], [[ns_paren]], [[ns_parseheader]], [[ns_parsequery]], [[ns_rand]], [[ns_resetcachedform]], [[ns_sendmail]], [[ns_sleep]], [[ns_sourceproc]], [[ns_url2file]], [[ns_urldecode]], [[ns_urlencode]], [[ns_uudecode]], [[ns_uuencode]], [[ns_zlib]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_filter&amp;diff=5836</id>
		<title>Ns register filter</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_filter&amp;diff=5836"/>
		<updated>2010-06-20T17:32:27Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{manpage|ns_filter}}&lt;br /&gt;
&lt;br /&gt;
'''NAME'''&lt;br /&gt;
&lt;br /&gt;
ns_register_filter - Register a filter or trace callback&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''SYNOPSIS'''&lt;br /&gt;
&lt;br /&gt;
'''ns_register_filter''' ''?-first? when method URLpatttern procname ?arg arg ...?''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''DESCRIPTION'''&lt;br /&gt;
&lt;br /&gt;
: Registers a Tcl filter script for the specified method/URL combination on a virtual server. The script can be called at one of several times as indicated by the ''when'' argument:&lt;br /&gt;
:* '''read''' - upcoming in AOLserver 4.6 - runs in the driver thread while in the ''read'' state in a ''different'' Tcl interpreter from the rest of the connection - procedure will not receive a conn id so should not have arguments(?) and normal [[ns_conn]] and similar commands will not work.&lt;br /&gt;
:* '''prequeue''' - runs in the driver thread while in the ''ready'' state in a ''different'' Tcl interpreter from the rest of the connection - new in AOLserver 4.5 but there are known memory leak issues that are fixed in upcoming AOLserver 4.6. Procedure will not receive a conn id so should not have arguments(?) and normal [[ns_conn]] and similar commands will not work.&lt;br /&gt;
:* '''preauth''' - pre-authorization&lt;br /&gt;
:* '''postauth'''- post-authorization before page data has been returned to the user&lt;br /&gt;
:* '''write''' - upcoming in AOLserver 4.6 - Invokes proc after each write to the client.  Server normally buffers response output so this callback is called potentially just once when flushing the connection output buffers.&lt;br /&gt;
:* '''trace''' - after the connection has been processed and closed.&lt;br /&gt;
&lt;br /&gt;
: The registered script will be called at the specified stage of a connection, if the method/URL combination for the filter matches the method/URL combination for the connection using glob style (i.e. as in string match) matching. For example, these are valid ''URLpatterns'':&lt;br /&gt;
&lt;br /&gt;
    /employees/*.tcl&lt;br /&gt;
    /accounts/*/out&lt;br /&gt;
&lt;br /&gt;
: Using pre-authorization, the procedure will be called (assuming that the method/URL combination matches) just before authorization. If the procedure returns with a code of:&lt;br /&gt;
&lt;br /&gt;
:* '''TCL_OK'''  (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next pre-authorization filter for this connection, or, if there are no more pre-authorization filters, it will continue on with authorization.&lt;br /&gt;
:* '''TCL_BREAK''' (using: return &amp;quot;filter_break&amp;quot;): The server will not process any more pre-authorization filters for this connection, and it will continue on with authorization.&lt;br /&gt;
:* '''TCL_RETURN''' (using: return &amp;quot;filter_return&amp;quot;): The server will close the connection and will not run any more pre-authorization filters. It will not authorize the request, and it will not run the function registered for this METHOD/URL. It WILL run any trace functions registered for this METHOD/URL, usually including logging. It is assumed that the filter has sent a proper response (e.g., using ns_return) to the client before returning TCL_RETURN.&lt;br /&gt;
&lt;br /&gt;
: Using post-authorization, the procedure will be called (assuming that the method/URL combination matches) just after successful authorization. If the procedure returns:&lt;br /&gt;
:* '''TCL_OK''' (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next post-authorization filter for this connection, or, if there are no more post-authorization filters, it will run the function registered to handle this request.&lt;br /&gt;
:* '''TCL_BREAK''' (using: return &amp;quot;filter_break&amp;quot;): The server will not process any more post-authorization filters for this connection, and it will run the function registered to handle this request.&lt;br /&gt;
:* '''TCL_RETURN''' (using: return &amp;quot;filter_return&amp;quot;): The server will close the connection and will not run any more post-authorization filters and it will not run the function registered for this METHOD/URL. It WILL run any trace functions registered for this METHOD/URL, usually including logging. It is assumed that the filter has returned a proper response (e.g., using ns_return) to the client before returning TCL_RETURN.&lt;br /&gt;
&lt;br /&gt;
: Using trace, the procedure will be called (assuming that the method/URL combination match) after the connection has been totally processed and closed. If the procedure returns:&lt;br /&gt;
:* '''TCL_OK''' (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next trace filter.&lt;br /&gt;
:* '''TCL_BREAK''' (using: return &amp;quot;filter_break&amp;quot;): The rest of the trace filters are ignored.&lt;br /&gt;
:* '''TCL_RETURN''' (using: return &amp;quot;filter_break&amp;quot;): The rest of the trace filters are ignored.&lt;br /&gt;
&lt;br /&gt;
'''Syntax for the registered procedure:'''&lt;br /&gt;
&lt;br /&gt;
: The ''conn'' (connection id) argument is optional for procedures registered by ns_register_filter if the procedure has 1 or 2 arguments (including why but not including ''conn''). The following examples show the variations that can be used in this case:&lt;br /&gt;
&lt;br /&gt;
    '''ns_register_filter''' ''trace'' GET /noargs filter_noargs&lt;br /&gt;
    '''ns_register_filter''' ''trace'' GET /context filter_context fnord&lt;br /&gt;
    '''ns_register_filter''' ''trace'' GET /conncontext filter_conncontext&lt;br /&gt;
&lt;br /&gt;
    proc filter_noargs { why } {&lt;br /&gt;
    ns_log Notice &amp;quot;filter noargs&amp;quot;&lt;br /&gt;
    return filter_ok&lt;br /&gt;
    } ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
    proc filter_context { arg why } {&lt;br /&gt;
    ns_log Notice &amp;quot;filter context. Arg: $arg&amp;quot;&lt;br /&gt;
    return filter_ok&lt;br /&gt;
    } ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
    proc filter_conncontext { conn arg why } {&lt;br /&gt;
    ns_log Notice &amp;quot;filter conn context&amp;quot;&lt;br /&gt;
    return filter_ok&lt;br /&gt;
    } ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
: The ''conn'' (connection) argument is required for procedures registered by '''ns_register_filter''' if the procedure has 3 or more arguments (including why but not including ''conn''). The ''conn'' argument is automatically filled with the connection id. The first argument following ''conn'' will always take the value supplied by '''ns_register_filter''', if there is one, or an empty value. The why argument at the end is automatically filled with the type of filter requested (the ''when'' it was registered for). All other arguments must supply a default value. The following examples show the variations that can be used in this case:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;&lt;br /&gt;
    '''ns_register_filter''' ''postauth'' GET /threeargs threeargs aaa&lt;br /&gt;
    '''ns_register_filter''' ''postauth'' GET /fourargs fourargs aaa bbb ccc&lt;br /&gt;
    &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    proc threeargs { conn context { greeble bork } why } {&lt;br /&gt;
    ...&lt;br /&gt;
    } ;&lt;br /&gt;
&lt;br /&gt;
    proc fourargs { conn context { greeble bork } {hoover quark} why } {&lt;br /&gt;
    ...&lt;br /&gt;
    } ;&lt;br /&gt;
&lt;br /&gt;
: When a GET of /threeargs is requested, the conn and why arguments will be filled automatically, the context argument will be assigned &amp;quot;aaa&amp;quot; and the greeble argument will be assigned the default value &amp;quot;bork&amp;quot;. When a GET of /fourargs is requested, the conn and why arguments will be filled automatically, the context argument will be assigned &amp;quot;aaa&amp;quot;, the greeble argument will be assigned &amp;quot;bbb&amp;quot;, and the hoover argument will be assigned the default value &amp;quot;quark&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
:  Note that the server detects the number of arguments in your procedure only the first time it is invoked as a filter/trace.  Therefore if you change the number of arguments after this, this change will not be recognized until after a server restart.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''NOTES'''&lt;br /&gt;
&lt;br /&gt;
: Note '''ns_register_filter''' (and _trace) is similar to '''[[ns_register_proc]]''' except that the pattern-matching for the URL is performed differently. With '''ns_register_proc''', the specified URL is used to match that URL and any URL below it in the hierarchy. Wildcards such as &amp;quot;*&amp;quot; are meaningful only for the final part of the URL, such as /scripts/*.tcl. With '''ns_register_filter''', the ''URLpattern'' is used to match URLs as a string with standard string-matching characters. '''ns_register_proc''' always results in a single match to just one procedure, whereas multiple procedures registered with '''ns_register_filter''' can be matched and will be called in the order they were registered.&lt;br /&gt;
&lt;br /&gt;
: In AOLserver 4.5.2, you can use the optional ''-first'' switch to specify that the procedure should go to the top of registered filters for a particular pattern and therefore to be called first.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: To be more precise the allowed matching characters in ''URLpattern'' are determined by [http://www.tcl.tk/man/tcl8.0/TclLib/StrMatch.htm Tcl_StrMatch] which in turn is determined by [http://www.tcl.tk/man/tcl8.0/TclCmd/string.htm#M10 TCL string match].&lt;br /&gt;
&lt;br /&gt;
'''SEE ALSO'''&lt;br /&gt;
&lt;br /&gt;
: '''[[ns_register_trace]]''' - very similar to '''ns_register_filter trace''' - known internally as ''void_traces'', procedures registered by this command fire after the procedures registered by '''ns_register_filter trace''' and differ in that they only execute if a response was successfully sent to the client (i.e. not a Server Error), plus their return value is ignored.  See '''[[ns_register_trace]]''' for more details.&lt;br /&gt;
&lt;br /&gt;
: '''[[ns_register_filter_shortcut]]''' ''when method URLpatttern'' (new in AOLserver 4.5.2)&lt;br /&gt;
&lt;br /&gt;
: '''[[ns_register_filter_error]]''' ''?-first? when method URLpatttern'' ([http://aolserver.am.net/code/modules/ampools.adpx ampools] module for AOLserver 4.5.2)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[[Category:Core Tcl API]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_filter&amp;diff=5835</id>
		<title>Ns register filter</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_filter&amp;diff=5835"/>
		<updated>2010-06-20T17:31:15Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{manpage|ns_filter}}&lt;br /&gt;
&lt;br /&gt;
'''NAME'''&lt;br /&gt;
&lt;br /&gt;
ns_register_filter - Register a filter or trace callback&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''SYNOPSIS'''&lt;br /&gt;
&lt;br /&gt;
'''ns_register_filter''' ''?-first? when method URLpatttern procname ?arg arg ...?''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''DESCRIPTION'''&lt;br /&gt;
&lt;br /&gt;
: Registers a Tcl filter script for the specified method/URL combination on a virtual server. The script can be called at one of several times as indicated by the ''when'' argument:&lt;br /&gt;
:* '''read''' - upcoming in AOLserver 4.6 - runs in the driver thread while in the ''read'' state in a ''different'' Tcl interpreter from the rest of the connection - procedure will not receive a conn id so should not have arguments(?) and normal [[ns_conn]] and similar commands will not work.&lt;br /&gt;
:* '''prequeue''' - runs in the driver thread while in the ''ready'' state in a ''different'' Tcl interpreter from the rest of the connection - new in AOLserver 4.5 but there are known memory leak issues that are fixed in upcoming AOLserver 4.6. Procedure will not receive a conn id so should not have arguments(?) and normal [[ns_conn]] and similar commands will not work.&lt;br /&gt;
:* '''preauth''' - pre-authorization&lt;br /&gt;
:* '''postauth'''- post-authorization before page data has been returned to the user&lt;br /&gt;
:* '''write''' - upcoming in AOLserver 4.6 - Invokes proc after each write to the client.  Server normally buffers response output so this callback is called potentially just once when flushing the connection output buffers.&lt;br /&gt;
:* '''trace''' - after the connection has been processed and closed.&lt;br /&gt;
&lt;br /&gt;
: The registered script will be called at the specified stage of a connection, if the method/URL combination for the filter matches the method/URL combination for the connection using glob style (i.e. as in string match) matching. For example, these are valid ''URLpatterns'':&lt;br /&gt;
&lt;br /&gt;
    /employees/*.tcl&lt;br /&gt;
    /accounts/*/out&lt;br /&gt;
&lt;br /&gt;
: Using pre-authorization, the procedure will be called (assuming that the method/URL combination matches) just before authorization. If the procedure returns with a code of:&lt;br /&gt;
&lt;br /&gt;
:* '''TCL_OK'''  (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next pre-authorization filter for this connection, or, if there are no more pre-authorization filters, it will continue on with authorization.&lt;br /&gt;
:* '''TCL_BREAK''' (using: return &amp;quot;filter_break&amp;quot;): The server will not process any more pre-authorization filters for this connection, and it will continue on with authorization.&lt;br /&gt;
:* '''TCL_RETURN''' (using: return &amp;quot;filter_return&amp;quot;): The server will close the connection and will not run any more pre-authorization filters. It will not authorize the request, and it will not run the function registered for this METHOD/URL. It WILL run any trace functions registered for this METHOD/URL, usually including logging. It is assumed that the filter has sent a proper response (e.g., using ns_return) to the client before returning TCL_RETURN.&lt;br /&gt;
&lt;br /&gt;
: Using post-authorization, the procedure will be called (assuming that the method/URL combination matches) just after successful authorization. If the procedure returns:&lt;br /&gt;
:* '''TCL_OK''' (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next post-authorization filter for this connection, or, if there are no more post-authorization filters, it will run the function registered to handle this request.&lt;br /&gt;
:* '''TCL_BREAK''' (using: return &amp;quot;filter_break&amp;quot;): The server will not process any more post-authorization filters for this connection, and it will run the function registered to handle this request.&lt;br /&gt;
:* '''TCL_RETURN''' (using: return &amp;quot;filter_return&amp;quot;): The server will close the connection and will not run any more post-authorization filters and it will not run the function registered for this METHOD/URL. It WILL run any trace functions registered for this METHOD/URL, usually including logging. It is assumed that the filter has returned a proper response (e.g., using ns_return) to the client before returning TCL_RETURN.&lt;br /&gt;
&lt;br /&gt;
: Using trace, the procedure will be called (assuming that the method/URL combination match) after the connection has been totally processed and closed. If the procedure returns:&lt;br /&gt;
:* '''TCL_OK''' (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next trace filter.&lt;br /&gt;
:* '''TCL_BREAK''' (using: return &amp;quot;filter_break&amp;quot;): The rest of the trace filters are ignored.&lt;br /&gt;
:* '''TCL_RETURN''' (using: return &amp;quot;filter_break&amp;quot;): The rest of the trace filters are ignored.&lt;br /&gt;
&lt;br /&gt;
'''Syntax for the registered procedure:'''&lt;br /&gt;
&lt;br /&gt;
: The ''conn'' (connection id) argument is optional for procedures registered by ns_register_filter if the procedure has 1 or 2 arguments (including why but not including ''conn''). The following examples show the variations that can be used in this case:&lt;br /&gt;
&lt;br /&gt;
    '''ns_register_filter''' ''trace'' GET /noargs filter_noargs&lt;br /&gt;
    '''ns_register_filter''' ''trace'' GET /context filter_context fnord&lt;br /&gt;
    '''ns_register_filter''' ''trace'' GET /conncontext filter_conncontext&lt;br /&gt;
&lt;br /&gt;
    proc filter_noargs { why } {&lt;br /&gt;
    ns_log Notice &amp;quot;filter noargs&amp;quot;&lt;br /&gt;
    return filter_ok&lt;br /&gt;
    } ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
    proc filter_context { arg why } {&lt;br /&gt;
    ns_log Notice &amp;quot;filter context. Arg: $arg&amp;quot;&lt;br /&gt;
    return filter_ok&lt;br /&gt;
    } ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
    proc filter_conncontext { conn arg why } {&lt;br /&gt;
    ns_log Notice &amp;quot;filter conn context&amp;quot;&lt;br /&gt;
    return filter_ok&lt;br /&gt;
    } ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
: The ''conn'' (connection) argument is required for procedures registered by '''ns_register_filter''' if the procedure has 3 or more arguments (including why but not including ''conn''). The ''conn'' argument is automatically filled with the connection id. The first argument following ''conn'' will always take the value supplied by '''ns_register_filter''', if there is one, or an empty value. The why argument at the end is automatically filled with the type of filter requested (the ''when'' it was registered for). All other arguments must supply a default value. The following examples show the variations that can be used in this case:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;&lt;br /&gt;
    '''ns_register_filter''' ''postauth'' GET /threeargs threeargs aaa&lt;br /&gt;
    '''ns_register_filter''' ''postauth'' GET /fourargs fourargs aaa bbb ccc&lt;br /&gt;
    &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    proc threeargs { conn context { greeble bork } why } {&lt;br /&gt;
    ...&lt;br /&gt;
    } ;&lt;br /&gt;
&lt;br /&gt;
    proc fourargs { conn context { greeble bork } {hoover quark} why } {&lt;br /&gt;
    ...&lt;br /&gt;
    } ;&lt;br /&gt;
&lt;br /&gt;
: When a GET of /threeargs is requested, the conn and why arguments will be filled automatically, the context argument will be assigned &amp;quot;aaa&amp;quot; and the greeble argument will be assigned the default value &amp;quot;bork&amp;quot;. When a GET of /fourargs is requested, the conn and why arguments will be filled automatically, the context argument will be assigned &amp;quot;aaa&amp;quot;, the greeble argument will be assigned &amp;quot;bbb&amp;quot;, and the hoover argument will be assigned the default value &amp;quot;quark&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
:  Note that the server detects the number of arguments in your procedure only the first time it is invoked as a filter/trace.  Therefore if you change the number of arguments after this, this change will not be recognized until after a server restart.&lt;br /&gt;
&lt;br /&gt;
==='''ns_register_trace:'''===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''NOTES'''&lt;br /&gt;
&lt;br /&gt;
: Note '''ns_register_filter''' (and _trace) is similar to '''[[ns_register_proc]]''' except that the pattern-matching for the URL is performed differently. With '''ns_register_proc''', the specified URL is used to match that URL and any URL below it in the hierarchy. Wildcards such as &amp;quot;*&amp;quot; are meaningful only for the final part of the URL, such as /scripts/*.tcl. With '''ns_register_filter''', the ''URLpattern'' is used to match URLs as a string with standard string-matching characters. '''ns_register_proc''' always results in a single match to just one procedure, whereas multiple procedures registered with '''ns_register_filter''' can be matched and will be called in the order they were registered.&lt;br /&gt;
&lt;br /&gt;
: In AOLserver 4.5.2, you can use the optional ''-first'' switch to specify that the procedure should go to the top of registered filters for a particular pattern and therefore to be called first.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: To be more precise the allowed matching characters in ''URLpattern'' are determined by [http://www.tcl.tk/man/tcl8.0/TclLib/StrMatch.htm Tcl_StrMatch] which in turn is determined by [http://www.tcl.tk/man/tcl8.0/TclCmd/string.htm#M10 TCL string match].&lt;br /&gt;
&lt;br /&gt;
'''SEE ALSO'''&lt;br /&gt;
&lt;br /&gt;
: '''[[ns_register_trace]]''' - very similar to '''ns_register_filter trace''' - known internally as ''void_traces'', procedures registered by this command fire after the procedures registered by '''ns_register_filter trace''' and differ in that they only execute if a response was successfully sent to the client (i.e. not a Server Error), plus their return value is ignored.  See '''[[ns_register_trace]]''' for more details.&lt;br /&gt;
&lt;br /&gt;
: '''[[ns_register_filter_shortcut]]''' ''when method URLpatttern'' (new in AOLserver 4.5.2)&lt;br /&gt;
&lt;br /&gt;
: '''[[ns_register_filter_error]]''' ''?-first? when method URLpatttern'' ([[http://aolserver.am.net/code/modules/ampools.adpx ampools]] module for AOLserver 4.5.2)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[[Category:Core Tcl API]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_filter&amp;diff=5834</id>
		<title>Ns register filter</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_filter&amp;diff=5834"/>
		<updated>2010-06-20T17:20:53Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{manpage|ns_filter}}&lt;br /&gt;
&lt;br /&gt;
'''NAME'''&lt;br /&gt;
&lt;br /&gt;
ns_register_filter, ns_register_trace - Register a filter or trace callback&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''SYNOPSIS'''&lt;br /&gt;
&lt;br /&gt;
'''ns_register_filter''' ''?-first? when method URLpatttern procname ?arg arg ...?''&lt;br /&gt;
&lt;br /&gt;
'''ns_register_trace''' ''method URLpatttern procname ?arg arg ...?''&lt;br /&gt;
&lt;br /&gt;
'''ns_register_filter_shortcut''' ''when method URLpatttern'' (new in AOLserver 4.5.2)&lt;br /&gt;
&lt;br /&gt;
'''ns_register_filter_error''' ''?-first? when method URLpatttern'' (ampools module for AOLserver 4.5.2.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''DESCRIPTION'''&lt;br /&gt;
&lt;br /&gt;
: Registers a Tcl filter script for the specified method/URL combination on a virtual server. The script can be called at one of several times as indicated by the ''when'' argument:&lt;br /&gt;
:* '''read''' - upcoming in AOLserver 4.6 - runs in the driver thread while in the ''read'' state in a ''different'' Tcl interpreter from the rest of the connection - procedure will not receive a conn id so should not have arguments(?) and normal [[ns_conn]] and similar commands will not work.&lt;br /&gt;
:* '''prequeue''' - runs in the driver thread while in the ''ready'' state in a ''different'' Tcl interpreter from the rest of the connection - new in AOLserver 4.5 but there are known memory leak issues that are fixed in upcoming AOLserver 4.6. Procedure will not receive a conn id so should not have arguments(?) and normal [[ns_conn]] and similar commands will not work.&lt;br /&gt;
:* '''preauth''' - pre-authorization&lt;br /&gt;
:* '''postauth'''- post-authorization before page data has been returned to the user&lt;br /&gt;
:* '''write''' - upcoming in AOLserver 4.6 - Invokes proc after each write to the client.  Server normally buffers response output so this callback is called potentially just once when flushing the connection output buffers.&lt;br /&gt;
:* '''trace''' - after the connection has been processed and closed.&lt;br /&gt;
&lt;br /&gt;
: The registered script will be called at the specified stage of a connection, if the method/URL combination for the filter matches the method/URL combination for the connection using glob style (i.e. as in string match) matching. For example, these are valid ''URLpatterns'':&lt;br /&gt;
&lt;br /&gt;
    /employees/*.tcl&lt;br /&gt;
    /accounts/*/out&lt;br /&gt;
&lt;br /&gt;
: Using pre-authorization, the procedure will be called (assuming that the method/URL combination matches) just before authorization. If the procedure returns with a code of:&lt;br /&gt;
&lt;br /&gt;
:* '''TCL_OK'''  (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next pre-authorization filter for this connection, or, if there are no more pre-authorization filters, it will continue on with authorization.&lt;br /&gt;
:* '''TCL_BREAK''' (using: return &amp;quot;filter_break&amp;quot;): The server will not process any more pre-authorization filters for this connection, and it will continue on with authorization.&lt;br /&gt;
:* '''TCL_RETURN''' (using: return &amp;quot;filter_return&amp;quot;): The server will close the connection and will not run any more pre-authorization filters. It will not authorize the request, and it will not run the function registered for this METHOD/URL. It WILL run any trace functions registered for this METHOD/URL, usually including logging. It is assumed that the filter has sent a proper response (e.g., using ns_return) to the client before returning TCL_RETURN.&lt;br /&gt;
&lt;br /&gt;
: Using post-authorization, the procedure will be called (assuming that the method/URL combination matches) just after successful authorization. If the procedure returns:&lt;br /&gt;
:* '''TCL_OK''' (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next post-authorization filter for this connection, or, if there are no more post-authorization filters, it will run the function registered to handle this request.&lt;br /&gt;
:* '''TCL_BREAK''' (using: return &amp;quot;filter_break&amp;quot;): The server will not process any more post-authorization filters for this connection, and it will run the function registered to handle this request.&lt;br /&gt;
:* '''TCL_RETURN''' (using: return &amp;quot;filter_return&amp;quot;): The server will close the connection and will not run any more post-authorization filters and it will not run the function registered for this METHOD/URL. It WILL run any trace functions registered for this METHOD/URL, usually including logging. It is assumed that the filter has returned a proper response (e.g., using ns_return) to the client before returning TCL_RETURN.&lt;br /&gt;
&lt;br /&gt;
: Using trace, the procedure will be called (assuming that the method/URL combination match) after the connection has been totally processed and closed. If the procedure returns:&lt;br /&gt;
:* '''TCL_OK''' (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next trace filter.&lt;br /&gt;
:* '''TCL_BREAK''' (using: return &amp;quot;filter_break&amp;quot;): The rest of the trace filters are ignored.&lt;br /&gt;
:* '''TCL_RETURN''' (using: return &amp;quot;filter_break&amp;quot;): The rest of the trace filters are ignored.&lt;br /&gt;
&lt;br /&gt;
'''Syntax for the registered procedure:'''&lt;br /&gt;
&lt;br /&gt;
: The ''conn'' (connection id) argument is optional for procedures registered by ns_register_filter if the procedure has 1 or 2 arguments (including why but not including ''conn''). The following examples show the variations that can be used in this case:&lt;br /&gt;
&lt;br /&gt;
    '''ns_register_filter''' ''trace'' GET /noargs filter_noargs&lt;br /&gt;
    '''ns_register_filter''' ''trace'' GET /context filter_context fnord&lt;br /&gt;
    '''ns_register_filter''' ''trace'' GET /conncontext filter_conncontext&lt;br /&gt;
&lt;br /&gt;
    proc filter_noargs { why } {&lt;br /&gt;
    ns_log Notice &amp;quot;filter noargs&amp;quot;&lt;br /&gt;
    return filter_ok&lt;br /&gt;
    } ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
    proc filter_context { arg why } {&lt;br /&gt;
    ns_log Notice &amp;quot;filter context. Arg: $arg&amp;quot;&lt;br /&gt;
    return filter_ok&lt;br /&gt;
    } ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
    proc filter_conncontext { conn arg why } {&lt;br /&gt;
    ns_log Notice &amp;quot;filter conn context&amp;quot;&lt;br /&gt;
    return filter_ok&lt;br /&gt;
    } ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
: The ''conn'' (connection) argument is required for procedures registered by '''ns_register_filter''' if the procedure has 3 or more arguments (including why but not including ''conn''). The ''conn'' argument is automatically filled with the connection id. The first argument following ''conn'' will always take the value supplied by '''ns_register_filter''', if there is one, or an empty value. The why argument at the end is automatically filled with the type of filter requested (the ''when'' it was registered for). All other arguments must supply a default value. The following examples show the variations that can be used in this case:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;&lt;br /&gt;
    '''ns_register_filter''' ''postauth'' GET /threeargs threeargs aaa&lt;br /&gt;
    '''ns_register_filter''' ''postauth'' GET /fourargs fourargs aaa bbb ccc&lt;br /&gt;
    &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    proc threeargs { conn context { greeble bork } why } {&lt;br /&gt;
    ...&lt;br /&gt;
    } ;&lt;br /&gt;
&lt;br /&gt;
    proc fourargs { conn context { greeble bork } {hoover quark} why } {&lt;br /&gt;
    ...&lt;br /&gt;
    } ;&lt;br /&gt;
&lt;br /&gt;
: When a GET of /threeargs is requested, the conn and why arguments will be filled automatically, the context argument will be assigned &amp;quot;aaa&amp;quot; and the greeble argument will be assigned the default value &amp;quot;bork&amp;quot;. When a GET of /fourargs is requested, the conn and why arguments will be filled automatically, the context argument will be assigned &amp;quot;aaa&amp;quot;, the greeble argument will be assigned &amp;quot;bbb&amp;quot;, and the hoover argument will be assigned the default value &amp;quot;quark&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==='''ns_register_trace:'''===&lt;br /&gt;
&lt;br /&gt;
: This command is very similar to '''ns_register_filter trace'''.  Known internally as ''void_traces'', procedures registered by this command fire after the procedures registered by '''ns_register_filter trace''' and differ in that they only execute if a response was successfully sent to the client (i.e. not a Server Error), plus their return value is ignored.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''NOTES'''&lt;br /&gt;
&lt;br /&gt;
: Note '''ns_register_filter''' (and _trace) is similar to '''[[ns_register_proc]]''' except that the pattern-matching for the URL is performed differently. With '''ns_register_proc''', the specified URL is used to match that URL and any URL below it in the hierarchy. Wildcards such as &amp;quot;*&amp;quot; are meaningful only for the final part of the URL, such as /scripts/*.tcl. With '''ns_register_filter''', the ''URLpattern'' is used to match URLs as a string with standard string-matching characters. '''ns_register_proc''' always results in a single match to just one procedure, whereas multiple procedures registered with '''ns_register_filter''' can be matched and will be called in the order they were registered.&lt;br /&gt;
&lt;br /&gt;
: In AOLserver 4.5.2, you can use the optional ''-first'' switch to specify that the procedure should go to the top of registered filters for a particular pattern and therefore to be called first.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: To be more precise the allowed matching characters in ''URLpattern'' are determined by [http://www.tcl.tk/man/tcl8.0/TclLib/StrMatch.htm Tcl_StrMatch] which in turn is determined by [http://www.tcl.tk/man/tcl8.0/TclCmd/string.htm#M10 TCL string match].&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[[Category:Core Tcl API]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_filter&amp;diff=5833</id>
		<title>Ns register filter</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_filter&amp;diff=5833"/>
		<updated>2010-06-20T04:48:43Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{manpage|ns_filter}}&lt;br /&gt;
&lt;br /&gt;
'''NAME'''&lt;br /&gt;
&lt;br /&gt;
ns_register_filter, ns_register_trace - Register a filter or trace callback&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''SYNOPSIS'''&lt;br /&gt;
&lt;br /&gt;
'''ns_register_filter''' ''?-first? when method URLpatttern procname ?arg arg ...?''&lt;br /&gt;
&lt;br /&gt;
'''ns_register_trace''' ''method URLpatttern procname ?arg arg ...?''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''DESCRIPTION'''&lt;br /&gt;
&lt;br /&gt;
: Registers a Tcl filter script for the specified method/URL combination on a virtual server. The script can be called at one of several times as indicated by the ''when'' argument:&lt;br /&gt;
:* '''read''' - upcoming in AOLserver 4.6 - runs in the driver thread while in the ''read'' state in a ''different'' Tcl interpreter from the rest of the connection - procedure will not receive a conn id so should not have arguments(?) and normal [[ns_conn]] and similar commands will not work.&lt;br /&gt;
:* '''prequeue''' - runs in the driver thread while in the ''ready'' state in a ''different'' Tcl interpreter from the rest of the connection - new in AOLserver 4.5 but there are known memory leak issues that are fixed in upcoming AOLserver 4.6. Procedure will not receive a conn id so should not have arguments(?) and normal [[ns_conn]] and similar commands will not work.&lt;br /&gt;
:* '''preauth''' - pre-authorization&lt;br /&gt;
:* '''postauth'''- post-authorization before page data has been returned to the user&lt;br /&gt;
:* '''write''' - Invokes proc after each write to the client.  Server normally buffers response output so this callback is called potentially just once when flushing the connection output buffers.&lt;br /&gt;
:* '''trace''' - after the connection has been processed and closed.&lt;br /&gt;
&lt;br /&gt;
: The registered script will be called at the specified stage of a connection, if the method/URL combination for the filter matches the method/URL combination for the connection using glob style (i.e. as in string match) matching. For example, these are valid ''URLpatterns'':&lt;br /&gt;
&lt;br /&gt;
    /employees/*.tcl&lt;br /&gt;
    /accounts/*/out&lt;br /&gt;
&lt;br /&gt;
: Using pre-authorization, the procedure will be called (assuming that the method/URL combination matches) just before authorization. If the procedure returns with a code of:&lt;br /&gt;
&lt;br /&gt;
:* '''TCL_OK'''  (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next pre-authorization filter for this connection, or, if there are no more pre-authorization filters, it will continue on with authorization.&lt;br /&gt;
:* '''TCL_BREAK''' (using: return &amp;quot;filter_break&amp;quot;): The server will not process any more pre-authorization filters for this connection, and it will continue on with authorization.&lt;br /&gt;
:* '''TCL_RETURN''' (using: return &amp;quot;filter_return&amp;quot;): The server will close the connection and will not run any more pre-authorization filters. It will not authorize the request, and it will not run the function registered for this METHOD/URL. It WILL run any trace functions registered for this METHOD/URL, usually including logging. It is assumed that the filter has sent a proper response (e.g., using ns_return) to the client before returning TCL_RETURN.&lt;br /&gt;
&lt;br /&gt;
: Using post-authorization, the procedure will be called (assuming that the method/URL combination matches) just after successful authorization. If the procedure returns:&lt;br /&gt;
:* '''TCL_OK''' (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next post-authorization filter for this connection, or, if there are no more post-authorization filters, it will run the function registered to handle this request.&lt;br /&gt;
:* '''TCL_BREAK''' (using: return &amp;quot;filter_break&amp;quot;): The server will not process any more post-authorization filters for this connection, and it will run the function registered to handle this request.&lt;br /&gt;
:* '''TCL_RETURN''' (using: return &amp;quot;filter_return&amp;quot;): The server will close the connection and will not run any more post-authorization filters and it will not run the function registered for this METHOD/URL. It WILL run any trace functions registered for this METHOD/URL, usually including logging. It is assumed that the filter has returned a proper response (e.g., using ns_return) to the client before returning TCL_RETURN.&lt;br /&gt;
&lt;br /&gt;
: Using trace, the procedure will be called (assuming that the method/URL combination match) after the connection has been totally processed and closed. If the procedure returns:&lt;br /&gt;
:* '''TCL_OK''' (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next trace filter.&lt;br /&gt;
:* '''TCL_BREAK''' (using: return &amp;quot;filter_break&amp;quot;): The rest of the trace filters are ignored.&lt;br /&gt;
:* '''TCL_RETURN''' (using: return &amp;quot;filter_break&amp;quot;): The rest of the trace filters are ignored.&lt;br /&gt;
&lt;br /&gt;
'''Syntax for the registered procedure:'''&lt;br /&gt;
&lt;br /&gt;
: The ''conn'' (connection id) argument is optional for procedures registered by ns_register_filter if the procedure has 1 or 2 arguments (including why but not including ''conn''). The following examples show the variations that can be used in this case:&lt;br /&gt;
&lt;br /&gt;
    '''ns_register_filter''' ''trace'' GET /noargs filter_noargs&lt;br /&gt;
    '''ns_register_filter''' ''trace'' GET /context filter_context fnord&lt;br /&gt;
    '''ns_register_filter''' ''trace'' GET /conncontext filter_conncontext&lt;br /&gt;
&lt;br /&gt;
    proc filter_noargs { why } {&lt;br /&gt;
    ns_log Notice &amp;quot;filter noargs&amp;quot;&lt;br /&gt;
    return filter_ok&lt;br /&gt;
    } ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
    proc filter_context { arg why } {&lt;br /&gt;
    ns_log Notice &amp;quot;filter context. Arg: $arg&amp;quot;&lt;br /&gt;
    return filter_ok&lt;br /&gt;
    } ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
    proc filter_conncontext { conn arg why } {&lt;br /&gt;
    ns_log Notice &amp;quot;filter conn context&amp;quot;&lt;br /&gt;
    return filter_ok&lt;br /&gt;
    } ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
: The ''conn'' (connection) argument is required for procedures registered by '''ns_register_filter''' if the procedure has 3 or more arguments (including why but not including ''conn''). The ''conn'' argument is automatically filled with the connection id. The first argument following ''conn'' will always take the value supplied by '''ns_register_filter''', if there is one, or an empty value. The why argument at the end is automatically filled with the type of filter requested (the ''when'' it was registered for). All other arguments must supply a default value. The following examples show the variations that can be used in this case:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;&lt;br /&gt;
    '''ns_register_filter''' ''postauth'' GET /threeargs threeargs aaa&lt;br /&gt;
    '''ns_register_filter''' ''postauth'' GET /fourargs fourargs aaa bbb ccc&lt;br /&gt;
    &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    proc threeargs { conn context { greeble bork } why } {&lt;br /&gt;
    ...&lt;br /&gt;
    } ;&lt;br /&gt;
&lt;br /&gt;
    proc fourargs { conn context { greeble bork } {hoover quark} why } {&lt;br /&gt;
    ...&lt;br /&gt;
    } ;&lt;br /&gt;
&lt;br /&gt;
: When a GET of /threeargs is requested, the conn and why arguments will be filled automatically, the context argument will be assigned &amp;quot;aaa&amp;quot; and the greeble argument will be assigned the default value &amp;quot;bork&amp;quot;. When a GET of /fourargs is requested, the conn and why arguments will be filled automatically, the context argument will be assigned &amp;quot;aaa&amp;quot;, the greeble argument will be assigned &amp;quot;bbb&amp;quot;, and the hoover argument will be assigned the default value &amp;quot;quark&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==='''ns_register_trace:'''===&lt;br /&gt;
&lt;br /&gt;
: This command is very similar to '''ns_register_filter trace'''.  Known internally as ''void_traces'', procedures registered by this command fire after the procedures registered by '''ns_register_filter trace''' and differ in that they only execute if a response was successfully sent to the client (i.e. not a Server Error), plus their return value is ignored.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''NOTES'''&lt;br /&gt;
&lt;br /&gt;
: Note '''ns_register_filter''' (and _trace) is similar to '''[[ns_register_proc]]''' except that the pattern-matching for the URL is performed differently. With '''ns_register_proc''', the specified URL is used to match that URL and any URL below it in the hierarchy. Wildcards such as &amp;quot;*&amp;quot; are meaningful only for the final part of the URL, such as /scripts/*.tcl. With '''ns_register_filter''', the ''URLpattern'' is used to match URLs as a string with standard string-matching characters. '''ns_register_proc''' always results in a single match to just one procedure, whereas multiple procedures registered with '''ns_register_filter''' can be matched and will be called in the order they were registered.&lt;br /&gt;
&lt;br /&gt;
: In AOLserver 4.5.2, you can use the optional ''-first'' switch to specify that the procedure should go to the top of registered filters for a particular pattern and therefore to be called first.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: To be more precise the allowed matching characters in ''URLpattern'' are determined by [http://www.tcl.tk/man/tcl8.0/TclLib/StrMatch.htm Tcl_StrMatch] which in turn is determined by [http://www.tcl.tk/man/tcl8.0/TclCmd/string.htm#M10 TCL string match].&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[[Category:Core Tcl API]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_filter&amp;diff=5832</id>
		<title>Ns register filter</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_filter&amp;diff=5832"/>
		<updated>2010-06-20T04:33:31Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{manpage|ns_filter}}&lt;br /&gt;
&lt;br /&gt;
'''NAME'''&lt;br /&gt;
&lt;br /&gt;
ns_register_filter, ns_register_trace - Register a filter or trace callback&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''SYNOPSIS'''&lt;br /&gt;
&lt;br /&gt;
'''ns_register_filter''' ''?-first? when method URLpatttern procname ?arg arg ...?''&lt;br /&gt;
&lt;br /&gt;
'''ns_register_trace''' ''method URLpatttern procname ?arg arg ...?''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''DESCRIPTION'''&lt;br /&gt;
&lt;br /&gt;
: Registers a Tcl filter script for the specified method/URL combination on a virtual server. The script can be called at one of several times as indicated by the ''when'' argument:&lt;br /&gt;
:* '''prequeue'''&lt;br /&gt;
:* '''preauth''' - pre-authorization&lt;br /&gt;
:* '''postauth'''- post-authorization before page data has been returned to the user&lt;br /&gt;
:* '''trace''' - after the connection has been processed and closed.&lt;br /&gt;
&lt;br /&gt;
: Also upcoming in AOLserver 4.6 are:&lt;br /&gt;
:* '''read'''&lt;br /&gt;
:* '''write'''&lt;br /&gt;
&lt;br /&gt;
: The registered script will be called at the specified stage of a connection, if the method/URL combination for the filter matches the method/URL combination for the connection using glob style (i.e. as in string match) matching. For example, these are valid ''URLpatterns'':&lt;br /&gt;
&lt;br /&gt;
    /employees/*.tcl&lt;br /&gt;
    /accounts/*/out&lt;br /&gt;
&lt;br /&gt;
: Using pre-authorization, the procedure will be called (assuming that the method/URL combination matches) just before authorization. If the procedure returns with a code of:&lt;br /&gt;
&lt;br /&gt;
:* '''TCL_OK'''  (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next pre-authorization filter for this connection, or, if there are no more pre-authorization filters, it will continue on with authorization.&lt;br /&gt;
:* '''TCL_BREAK''' (using: return &amp;quot;filter_break&amp;quot;): The server will not process any more pre-authorization filters for this connection, and it will continue on with authorization.&lt;br /&gt;
:* '''TCL_RETURN''' (using: return &amp;quot;filter_return&amp;quot;): The server will close the connection and will not run any more pre-authorization filters. It will not authorize the request, and it will not run the function registered for this METHOD/URL. It WILL run any trace functions registered for this METHOD/URL, usually including logging. It is assumed that the filter has sent a proper response (e.g., using ns_return) to the client before returning TCL_RETURN.&lt;br /&gt;
&lt;br /&gt;
: Using post-authorization, the procedure will be called (assuming that the method/URL combination matches) just after successful authorization. If the procedure returns:&lt;br /&gt;
:* '''TCL_OK''' (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next post-authorization filter for this connection, or, if there are no more post-authorization filters, it will run the function registered to handle this request.&lt;br /&gt;
:* '''TCL_BREAK''' (using: return &amp;quot;filter_break&amp;quot;): The server will not process any more post-authorization filters for this connection, and it will run the function registered to handle this request.&lt;br /&gt;
:* '''TCL_RETURN''' (using: return &amp;quot;filter_return&amp;quot;): The server will close the connection and will not run any more post-authorization filters and it will not run the function registered for this METHOD/URL. It WILL run any trace functions registered for this METHOD/URL, usually including logging. It is assumed that the filter has returned a proper response (e.g., using ns_return) to the client before returning TCL_RETURN.&lt;br /&gt;
&lt;br /&gt;
: Using trace, the procedure will be called (assuming that the method/URL combination match) after the connection has been totally AND successfully processed (i.e. not a Server Error) and closed. If the procedure returns:&lt;br /&gt;
:* '''TCL_OK''' (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next trace filter.&lt;br /&gt;
:* '''TCL_BREAK''' (using: return &amp;quot;filter_break&amp;quot;): The rest of the trace filters are ignored.&lt;br /&gt;
:* '''TCL_RETURN''' (using: return &amp;quot;filter_break&amp;quot;): The rest of the trace filters are ignored.&lt;br /&gt;
&lt;br /&gt;
'''Syntax for the registered procedure:'''&lt;br /&gt;
&lt;br /&gt;
The ''conn'' (connection id) argument is optional for procedures registered by ns_register_filter if the procedure has 1 or 2 arguments (including why but not including ''conn''). The following examples show the variations that can be used in this case:&lt;br /&gt;
&lt;br /&gt;
    '''ns_register_filter''' ''trace'' GET /noargs filter_noargs&lt;br /&gt;
    '''ns_register_filter''' ''trace'' GET /context filter_context fnord&lt;br /&gt;
    '''ns_register_filter''' ''trace'' GET /conncontext filter_conncontext&lt;br /&gt;
&lt;br /&gt;
    proc filter_noargs { why } {&lt;br /&gt;
    ns_log Notice &amp;quot;filter noargs&amp;quot;&lt;br /&gt;
    return filter_ok&lt;br /&gt;
    } ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
    proc filter_context { arg why } {&lt;br /&gt;
    ns_log Notice &amp;quot;filter context. Arg: $arg&amp;quot;&lt;br /&gt;
    return filter_ok&lt;br /&gt;
    } ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
    proc filter_conncontext { conn arg why } {&lt;br /&gt;
    ns_log Notice &amp;quot;filter conn context&amp;quot;&lt;br /&gt;
    return filter_ok&lt;br /&gt;
    } ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
: The ''conn'' (connection) argument is required for procedures registered by '''ns_register_filter''' if the procedure has 3 or more arguments (including why but not including ''conn''). The ''conn'' argument is automatically filled with the connection id. The first argument following ''conn'' will always take the value supplied by '''ns_register_filter''', if there is one, or an empty value. The why argument at the end is automatically filled with the type of filter requested (the ''when'' it was registered for). All other arguments must supply a default value. The following examples show the variations that can be used in this case:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;&lt;br /&gt;
    '''ns_register_filter''' ''postauth'' GET /threeargs threeargs aaa&lt;br /&gt;
    '''ns_register_filter''' ''postauth'' GET /fourargs fourargs aaa bbb ccc&lt;br /&gt;
    &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    proc threeargs { conn context { greeble bork } why } {&lt;br /&gt;
    ...&lt;br /&gt;
    } ;&lt;br /&gt;
&lt;br /&gt;
    proc fourargs { conn context { greeble bork } {hoover quark} why } {&lt;br /&gt;
    ...&lt;br /&gt;
    } ;&lt;br /&gt;
&lt;br /&gt;
: When a GET of /threeargs is requested, the conn and why arguments will be filled automatically, the context argument will be assigned &amp;quot;aaa&amp;quot; and the greeble argument will be assigned the default value &amp;quot;bork&amp;quot;. When a GET of /fourargs is requested, the conn and why arguments will be filled automatically, the context argument will be assigned &amp;quot;aaa&amp;quot;, the greeble argument will be assigned &amp;quot;bbb&amp;quot;, and the hoover argument will be assigned the default value &amp;quot;quark&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==='''ns_register_trace:'''===&lt;br /&gt;
&lt;br /&gt;
: This command is very similar to '''ns_register_filter trace'''.  Known internally as ''void_traces'', procedures registered by this command fire after the procedures registered by '''ns_register_filter trace''' and differ in that their return value is ignored.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''NOTES'''&lt;br /&gt;
&lt;br /&gt;
: Note '''ns_register_filter''' (and _trace) is similar to '''[[ns_register_proc]]''' except that the pattern-matching for the URL is performed differently. With '''ns_register_proc''', the specified URL is used to match that URL and any URL below it in the hierarchy. Wildcards such as &amp;quot;*&amp;quot; are meaningful only for the final part of the URL, such as /scripts/*.tcl. With '''ns_register_filter''', the ''URLpattern'' is used to match URLs as a string with standard string-matching characters. '''ns_register_proc''' always results in a single match to just one procedure, whereas multiple procedures registered with '''ns_register_filter''' can be matched and will be called in the order they were registered.&lt;br /&gt;
&lt;br /&gt;
: In AOLserver 4.5.2, you can use the optional ''-first'' switch to specify that the procedure should go to the top of registered filters for a particular pattern and therefore to be called first.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: To be more precise the allowed matching characters in ''URLpattern'' are determined by [http://www.tcl.tk/man/tcl8.0/TclLib/StrMatch.htm Tcl_StrMatch] which in turn is determined by [http://www.tcl.tk/man/tcl8.0/TclCmd/string.htm#M10 TCL string match].&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[[Category:Core Tcl API]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_filter&amp;diff=5831</id>
		<title>Ns register filter</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_filter&amp;diff=5831"/>
		<updated>2010-06-20T04:29:47Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{manpage|ns_filter}}&lt;br /&gt;
&lt;br /&gt;
'''NAME'''&lt;br /&gt;
&lt;br /&gt;
ns_register_filter, ns_register_trace - Register a filter or trace callback&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''SYNOPSIS'''&lt;br /&gt;
&lt;br /&gt;
'''ns_register_filter''' ''?-first? when method URLpatttern procname ?arg arg ...?''&lt;br /&gt;
&lt;br /&gt;
'''ns_register_trace''' ''method URLpatttern procname ?arg arg ...?''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''DESCRIPTION'''&lt;br /&gt;
&lt;br /&gt;
: Registers a Tcl filter script for the specified method/URL combination on a virtual server. The script can be called at one of several times as indicated by the ''when'' argument:&lt;br /&gt;
* '''prequeue'''&lt;br /&gt;
* '''preauth''' - pre-authorization&lt;br /&gt;
* '''postauth'''- post-authorization before page data has been returned to the user&lt;br /&gt;
* '''trace''' - after the connection has been processed and closed.&lt;br /&gt;
&lt;br /&gt;
: Also upcoming in AOLserver 4.6 are:&lt;br /&gt;
* '''read'''&lt;br /&gt;
* '''write'''&lt;br /&gt;
&lt;br /&gt;
: The registered script will be called at the specified stage of a connection, if the method/URL combination for the filter matches the method/URL combination for the connection using glob style (i.e. as in string match) matching. For example, these are valid ''URLpatterns'':&lt;br /&gt;
&lt;br /&gt;
    /employees/*.tcl&lt;br /&gt;
    /accounts/*/out&lt;br /&gt;
&lt;br /&gt;
: Using pre-authorization, the procedure will be called (assuming that the method/URL combination matches) just before authorization. If the procedure returns with a code of:&lt;br /&gt;
&lt;br /&gt;
* '''TCL_OK'''&lt;br /&gt;
: (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next pre-authorization filter for this connection, or, if there are no more pre-authorization filters, it will continue on with authorization.&lt;br /&gt;
* '''TCL_BREAK'''&lt;br /&gt;
: (using: return &amp;quot;filter_break&amp;quot;): The server will not process any more pre-authorization filters for this connection, and it will continue on with authorization.&lt;br /&gt;
* '''TCL_RETURN'''&lt;br /&gt;
: (using: return &amp;quot;filter_return&amp;quot;): The server will close the connection and will not run any more pre-authorization filters. It will not authorize the request, and it will not run the function registered for this METHOD/URL. It WILL run any trace functions registered for this METHOD/URL, usually including logging. It is assumed that the filter has sent a proper response (e.g., using ns_return) to the client before returning TCL_RETURN.&lt;br /&gt;
&lt;br /&gt;
: Using post-authorization, the procedure will be called (assuming that the method/URL combination matches) just after successful authorization. If the procedure returns:&lt;br /&gt;
* '''TCL_OK'''&lt;br /&gt;
: (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next post-authorization filter for this connection, or, if there are no more post-authorization filters, it will run the function registered to handle this request.&lt;br /&gt;
* '''TCL_BREAK'''&lt;br /&gt;
: (using: return &amp;quot;filter_break&amp;quot;): The server will not process any more post-authorization filters for this connection, and it will run the function registered to handle this request.&lt;br /&gt;
* '''TCL_RETURN'''&lt;br /&gt;
: (using: return &amp;quot;filter_return&amp;quot;): The server will close the connection and will not run any more post-authorization filters and it will not run the function registered for this METHOD/URL. It WILL run any trace functions registered for this METHOD/URL, usually including logging. It is assumed that the filter has returned a proper response (e.g., using ns_return) to the client before returning TCL_RETURN.&lt;br /&gt;
&lt;br /&gt;
: Using trace, the procedure will be called (assuming that the method/URL combination match) after the connection has been totally AND successfully processed (i.e. not a Server Error) and closed. If the procedure returns:&lt;br /&gt;
* '''TCL_OK'''&lt;br /&gt;
: (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next trace filter.&lt;br /&gt;
* '''TCL_BREAK'''&lt;br /&gt;
: (using: return &amp;quot;filter_break&amp;quot;): The rest of the trace filters are ignored.&lt;br /&gt;
* '''TCL_RETURN'''&lt;br /&gt;
: (using: return &amp;quot;filter_break&amp;quot;): The rest of the trace filters are ignored.&lt;br /&gt;
&lt;br /&gt;
'''Syntax for the registered procedure:'''&lt;br /&gt;
&lt;br /&gt;
The ''conn'' (connection id) argument is optional for procedures registered by ns_register_filter if the procedure has 1 or 2 arguments (including why but not including ''conn''). The following examples show the variations that can be used in this case:&lt;br /&gt;
&lt;br /&gt;
    '''ns_register_filter''' ''trace'' GET /noargs filter_noargs&lt;br /&gt;
    '''ns_register_filter''' ''trace'' GET /context filter_context fnord&lt;br /&gt;
    '''ns_register_filter''' ''trace'' GET /conncontext filter_conncontext&lt;br /&gt;
&lt;br /&gt;
    proc filter_noargs { why } {&lt;br /&gt;
    ns_log Notice &amp;quot;filter noargs&amp;quot;&lt;br /&gt;
    return filter_ok&lt;br /&gt;
    } ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
    proc filter_context { arg why } {&lt;br /&gt;
    ns_log Notice &amp;quot;filter context. Arg: $arg&amp;quot;&lt;br /&gt;
    return filter_ok&lt;br /&gt;
    } ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
    proc filter_conncontext { conn arg why } {&lt;br /&gt;
    ns_log Notice &amp;quot;filter conn context&amp;quot;&lt;br /&gt;
    return filter_ok&lt;br /&gt;
    } ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
: The ''conn'' (connection) argument is required for procedures registered by '''ns_register_filter''' if the procedure has 3 or more arguments (including why but not including ''conn''). The ''conn'' argument is automatically filled with the connection id. The first argument following ''conn'' will always take the value supplied by '''ns_register_filter''', if there is one, or an empty value. The why argument at the end is automatically filled with the type of filter requested (the ''when'' it was registered for). All other arguments must supply a default value. The following examples show the variations that can be used in this case:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;&lt;br /&gt;
    '''ns_register_filter''' ''postauth'' GET /threeargs threeargs aaa&lt;br /&gt;
    '''ns_register_filter''' ''postauth'' GET /fourargs fourargs aaa bbb ccc&lt;br /&gt;
    &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    proc threeargs { conn context { greeble bork } why } {&lt;br /&gt;
    ...&lt;br /&gt;
    } ;&lt;br /&gt;
&lt;br /&gt;
    proc fourargs { conn context { greeble bork } {hoover quark} why } {&lt;br /&gt;
    ...&lt;br /&gt;
    } ;&lt;br /&gt;
&lt;br /&gt;
: When a GET of /threeargs is requested, the conn and why arguments will be filled automatically, the context argument will be assigned &amp;quot;aaa&amp;quot; and the greeble argument will be assigned the default value &amp;quot;bork&amp;quot;. When a GET of /fourargs is requested, the conn and why arguments will be filled automatically, the context argument will be assigned &amp;quot;aaa&amp;quot;, the greeble argument will be assigned &amp;quot;bbb&amp;quot;, and the hoover argument will be assigned the default value &amp;quot;quark&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==='''ns_register_trace:'''===&lt;br /&gt;
&lt;br /&gt;
: This command is very similar to '''ns_register_filter trace'''.  Known internally as ''void_traces'', procedures registered by this command fire after the procedures registered by '''ns_register_filter trace''' and differ in that their return value is ignored.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''NOTES'''&lt;br /&gt;
&lt;br /&gt;
: Note '''ns_register_filter''' (and _trace) is similar to '''[[ns_register_proc]]''' except that the pattern-matching for the URL is performed differently. With '''ns_register_proc''', the specified URL is used to match that URL and any URL below it in the hierarchy. Wildcards such as &amp;quot;*&amp;quot; are meaningful only for the final part of the URL, such as /scripts/*.tcl. With '''ns_register_filter''', the ''URLpattern'' is used to match URLs as a string with standard string-matching characters. '''ns_register_proc''' always results in a single match to just one procedure, whereas multiple procedures registered with '''ns_register_filter''' can be matched and will be called in the order they were registered.  In AOLserver 4.5.2, you can use the optional ''-first'' switch to specify that the procedure should go to the top of registered filters for a particular pattern and therefore to be called first.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: To be more precise the allowed matching characters in ''URLpattern'' are determined by [http://www.tcl.tk/man/tcl8.0/TclLib/StrMatch.htm Tcl_StrMatch] which in turn is determined by [http://www.tcl.tk/man/tcl8.0/TclCmd/string.htm#M10 TCL string match].&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[[Category:Core Tcl API]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_filter&amp;diff=5830</id>
		<title>Ns register filter</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_filter&amp;diff=5830"/>
		<updated>2010-06-20T02:59:15Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{manpage|ns_filter}}&lt;br /&gt;
&lt;br /&gt;
'''NAME'''&lt;br /&gt;
&lt;br /&gt;
ns_register_filter, ns_register_trace - Register a filter or trace callback&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''SYNOPSIS'''&lt;br /&gt;
&lt;br /&gt;
 '''ns_register_filter''' ''when method url procname ?arg arg ...?''&lt;br /&gt;
&lt;br /&gt;
'''ns_register_trace''' method url procname ?arg arg ...?''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''DESCRIPTION'''&lt;br /&gt;
&lt;br /&gt;
: Registers a Tcl filter script for the specified method/URL combination on a virtual server. The script can be called at one or more of three given times: pre-authorization, post-authorization before page data has been returned to the user, and after the connection has been processed and closed.&lt;br /&gt;
&lt;br /&gt;
: This function will be called at the specified stage of a connection, if the method/URL combination for the filter matches the method/URL combination for the connection using glob style matching.&lt;br /&gt;
&lt;br /&gt;
: The URLpattern can contain standard string match glob matching characters (not regex). For example, these are valid URL patterns:&lt;br /&gt;
&lt;br /&gt;
    /employees/*.tcl&lt;br /&gt;
&lt;br /&gt;
    /accounts/*/out&lt;br /&gt;
&lt;br /&gt;
: Valid values for the &amp;quot;when&amp;quot; argument are: '''prequeue''', '''preauth''', '''postauth''', and '''trace''' (and upcoming in AOLserver 4.6 also '''read''' and '''write''').&lt;br /&gt;
: Using pre-authorization, the procedure will be called (assuming that the method/URL combination matches) just before authorization. If the procedure returns with a code of:&lt;br /&gt;
&lt;br /&gt;
; '''TCL_OK'''&lt;br /&gt;
: (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next pre-authorization filter for this connection, or, if there are no more pre-authorization filters, it will continue on with authorization.&lt;br /&gt;
; '''TCL_BREAK'''&lt;br /&gt;
: (using: return &amp;quot;filter_break&amp;quot;): The server will not process any more pre-authorization filters for this connection, and it will continue on with authorization.&lt;br /&gt;
; '''TCL_RETURN'''&lt;br /&gt;
: (using: return &amp;quot;filter_return&amp;quot;): The server will close the connection and will not run any more pre-authorization filters. It will not authorize the request, and it will not run the function registered for this METHOD/URL. It WILL run any trace functions registered for this METHOD/URL, usually including logging. It is assumed that the filter has sent a proper response (e.g., using ns_return) to the client before returning TCL_RETURN.&lt;br /&gt;
; Using post-authorization, the procedure will be called (assuming that the method/URL combination matches) just after successful authorization. If the procedure returns:&lt;br /&gt;
; '''TCL_OK'''&lt;br /&gt;
: (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next post-authorization filter for this connection, or, if there are no more post-authorization filters, it will run the function registered to handle this request.&lt;br /&gt;
; '''TCL_BREAK'''&lt;br /&gt;
: (using: return &amp;quot;filter_break&amp;quot;): The server will not process any more post-authorization filters for this connection, and it will run the function registered to handle this request.&lt;br /&gt;
; '''TCL_RETURN'''&lt;br /&gt;
: (using: return &amp;quot;filter_return&amp;quot;): The server will close the connection and will not run any more post-authorization filters and it will not run the function registered for this METHOD/URL. It WILL run any trace functions registered for this METHOD/URL, usually including logging. It is assumed that the filter has returned a proper response (e.g., using ns_return) to the client before returning TCL_RETURN.&lt;br /&gt;
; Using trace, the procedure will be called (assuming that the method/URL combination match) after the connection has been totally processed and closed. If the procedure returns:&lt;br /&gt;
; '''TCL_OK'''&lt;br /&gt;
: (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next trace filter.&lt;br /&gt;
; '''TCL_BREAK'''&lt;br /&gt;
: (using: return &amp;quot;filter_break&amp;quot;): The rest of the trace filters are ignored.&lt;br /&gt;
; '''TCL_RETURN'''&lt;br /&gt;
: (using: return &amp;quot;filter_break&amp;quot;): The rest of the trace filters are ignored.&lt;br /&gt;
&lt;br /&gt;
'''Syntax for the registered procedure:'''&lt;br /&gt;
&lt;br /&gt;
The conn (connection) argument is optional for procedures registered by ns_register_filter if the procedure has 1 or 2 arguments (including why but not including conn). The following examples show the variations that can be used in this case:&lt;br /&gt;
&lt;br /&gt;
    '''ns_register_filter''' ''trace'' GET /noargs filter_noargs&lt;br /&gt;
    '''ns_register_filter''' ''trace'' GET /context filter_context fnord&lt;br /&gt;
    '''ns_register_filter''' ''trace'' GET /conncontext filter_conncontext&lt;br /&gt;
&lt;br /&gt;
    proc filter_noargs { why } {&lt;br /&gt;
    ns_log Notice &amp;quot;filter noargs&amp;quot;&lt;br /&gt;
    return filter_ok&lt;br /&gt;
    } ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
    proc filter_context { arg why } {&lt;br /&gt;
    ns_log Notice &amp;quot;filter context. Arg: $arg&amp;quot;&lt;br /&gt;
    return filter_ok&lt;br /&gt;
    } ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
    proc filter_conncontext { conn arg why } {&lt;br /&gt;
    ns_log Notice &amp;quot;filter conn context&amp;quot;&lt;br /&gt;
    return filter_ok&lt;br /&gt;
    } ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
: The conn (connection) argument is required for procedures registered by ns_register_filter if the procedure has 3 or more arguments (including why but not including conn). The conn argument is automatically filled with the connection information. The first argument following conn will always take the value supplied by ns_register_filter, if there is one, or an empty value. The why argument at the end is automatically filled with the type of filter requested. All other arguments must supply a default value. The following examples show the variations that can be used in this case:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt; '''ns_register_filter''' ''postauth'' GET /threeargs threeargs aaa&lt;br /&gt;
    '''ns_register_filter''' ''postauth'' GET /fourargs fourargs aaa bbb ccc&lt;br /&gt;
    &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    proc threeargs { conn context { greeble bork } why } {&lt;br /&gt;
    ...&lt;br /&gt;
    } ;&lt;br /&gt;
&lt;br /&gt;
    proc fourargs { conn context { greeble bork } {hoover quark} why } {&lt;br /&gt;
    ...&lt;br /&gt;
    } ;&lt;br /&gt;
&lt;br /&gt;
: When a GET of /threeargs is requested, the conn and why arguments will be filled automatically, the context argument will be assigned &amp;quot;aaa&amp;quot; and the greeble argument will be assigned the default value &amp;quot;bork&amp;quot;. When a GET of /fourargs is requested, the conn and why arguments will be filled automatically, the context argument will be assigned &amp;quot;aaa&amp;quot;, the greeble argument will be assigned &amp;quot;bbb&amp;quot;, and the hoover argument will be assigned the default value &amp;quot;quark&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==='''ns_register_trace:'''===&lt;br /&gt;
&lt;br /&gt;
; Register a Tcl trace script to a method and matching URL.&lt;br /&gt;
: (Note: This function is obsolete. Use '''ns_register_filter''' instead.)&lt;br /&gt;
&lt;br /&gt;
: '''ns_register_trace''' registers a Tcl script as a trace for the specified method/URL combination. After the server handles the request for the specified method on an URL that matches the ''URLpattern'', it calls the trace script with the connection id and any arguments (args) specified. The ''URLpattern'' can contain standard string-matching characters. For example, these are valid URLpatterns:&lt;br /&gt;
&lt;br /&gt;
    /employees/*.tcl /accounts/*/out&lt;br /&gt;
&lt;br /&gt;
: Note '''ns_register_trace''' is similar to '''ns_register_proc''' except that the pattern-matching for the URL is performed differently. With '''ns_register_proc''', the specified URL is used to match that URL and any URL below it in the hierarchy. Wildcards such as &amp;quot;*&amp;quot; are meaningful only for the final part of the URL, such as /scripts/*.tcl. With '''ns_register_trace''', the ''URLpattern'' is used to match URLs as a string with standard string-matching characters. '''ns_register_proc''' results in a single match, whereas multiple ns_register_trace’s can be matched and will be called.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''NOTES'''&lt;br /&gt;
&lt;br /&gt;
: To be more precise the allowed matching characters are determined by [http://www.tcl.tk/man/tcl8.0/TclLib/StrMatch.htm Tcl_StrMatch] which in turn is determined by [http://www.tcl.tk/man/tcl8.0/TclCmd/string.htm#M10 TCL string match].&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[[Category:Core Tcl API]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_filter&amp;diff=5829</id>
		<title>Ns register filter</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_filter&amp;diff=5829"/>
		<updated>2010-06-20T02:48:34Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{manpage|ns_filter}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[http://aolserver.com/man/4.0/tcl/ns_filter.html#toc0 Name] ns_register_filter, ns_register_proc, ns_register_trace - Register a filter, proc or trace callback &amp;lt;/div&amp;gt; &amp;lt;div&amp;gt; [http://aolserver.com/man/4.0/tcl/ns_filter.html#toc1 Synopsis] '''ns_register_filter ''option '''''?''arg arg ...''?&lt;br /&gt;
&lt;br /&gt;
'''ns_register_proc ''option '''''?''arg arg ...''?&lt;br /&gt;
&lt;br /&gt;
'''ns_register_trace ''option '''''?''arg arg ...''?&lt;br /&gt;
&lt;br /&gt;
 [http://aolserver.com/man/4.0/tcl/ns_filter.html#toc2 Description]&lt;br /&gt;
&lt;br /&gt;
=== [http://aolserver.com/man/4.0/tcl/ns_filter.html#toc3 ns_register_filter:] ===&lt;br /&gt;
&lt;br /&gt;
Registers a Tcl filter script for the specified method/URL combination on a virtual server. The script can be called at one or more of three given times: pre-authorization, post-authorization before page data has been returned to the user, and after the connection has been processed and closed.&lt;br /&gt;
&lt;br /&gt;
This function will be called at the specified stage of a connection, if the method/URL combination for the filter matches the method/URL combination for the connection using glob style matching.&lt;br /&gt;
&lt;br /&gt;
The URLpattern can contain standard string-matching characters. For example, these are valid URL patterns:&lt;br /&gt;
&lt;br /&gt;
/employees/*.tcl&lt;br /&gt;
&lt;br /&gt;
/accounts/*/out&lt;br /&gt;
&lt;br /&gt;
Valid values for the &amp;quot;when&amp;quot; argument are: preauth, postauth, and trace. Using pre-authorization, the procedure will be called (assuming that the method/URL combination matches) just before authorization. If the procedure returns with a code of:&lt;br /&gt;
&lt;br /&gt;
; '''TCL_OK'''&lt;br /&gt;
: (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next pre-authorization filter for this connection, or, if there are no more pre-authorization filters, it will continue on with authorization.&lt;br /&gt;
; '''TCL_BREAK'''&lt;br /&gt;
: (using: return &amp;quot;filter_break&amp;quot;): The server will not process any more pre-authorization filters for this connection, and it will continue on with authorization.&lt;br /&gt;
; '''TCL_RETURN'''&lt;br /&gt;
: (using: return &amp;quot;filter_return&amp;quot;): The server will close the connection and will not run any more pre-authorization filters. It will not authorize the request, and it will not run the function registered for this METHOD/URL. It WILL run any trace functions registered for this METHOD/URL, usually including logging. It is assumed that the filter has sent a proper response (e.g., using ns_return) to the client before returning TCL_RETURN.&lt;br /&gt;
; Using post-authorization, the procedure will be called (assuming that the method/URL combination matches) just after successful authorization. If the procedure returns:&lt;br /&gt;
; '''TCL_OK'''&lt;br /&gt;
: (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next post-authorization filter for this connection, or, if there are no more post-authorization filters, it will run the function registered to handle this request.&lt;br /&gt;
; '''TCL_BREAK'''&lt;br /&gt;
: (using: return &amp;quot;filter_break&amp;quot;): The server will not process any more post-authorization filters for this connection, and it will run the function registered to handle this request.&lt;br /&gt;
; '''TCL_RETURN'''&lt;br /&gt;
: (using: return &amp;quot;filter_return&amp;quot;): The server will close the connection and will not run any more post-authorization filters and it will not run the function registered for this METHOD/URL. It WILL run any trace functions registered for this METHOD/URL, usually including logging. It is assumed that the filter has returned a proper response (e.g., using ns_return) to the client before returning TCL_RETURN.&lt;br /&gt;
; Using trace, the procedure will be called (assuming that the method/URL combination match) after the connection has been totally processed and closed. If the procedure returns:&lt;br /&gt;
; '''TCL_OK'''&lt;br /&gt;
: (using: return &amp;quot;filter_ok&amp;quot;): The server will continue to the next trace filter.&lt;br /&gt;
; '''TCL_BREAK'''&lt;br /&gt;
: (using: return &amp;quot;filter_break&amp;quot;): The rest of the trace filters are ignored.&lt;br /&gt;
; '''TCL_RETURN'''&lt;br /&gt;
: (using: return &amp;quot;filter_break&amp;quot;): The rest of the trace filters are ignored.&lt;br /&gt;
&lt;br /&gt;
'''Syntax for the registered procedure:'''&lt;br /&gt;
&lt;br /&gt;
The conn (connection) argument is optional for procedures registered by ns_register_filter if the procedure has 1 or 2 arguments (including why but not including conn). The following examples show the variations that can be used in this case:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''ns_register_filter''' ''trace'' GET /noargs filter_noargs&lt;br /&gt;
'''ns_register_filter''' ''trace'' GET /context filter_context fnord&lt;br /&gt;
'''ns_register_filter''' ''trace'' GET /conncontext filter_conncontext&lt;br /&gt;
&lt;br /&gt;
proc filter_noargs { why } {&lt;br /&gt;
ns_log Notice &amp;quot;filter noargs&amp;quot;&lt;br /&gt;
return filter_ok&lt;br /&gt;
} ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
proc filter_context { arg why } {&lt;br /&gt;
ns_log Notice &amp;quot;filter context. Arg: $arg&amp;quot;&lt;br /&gt;
return filter_ok&lt;br /&gt;
} ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
proc filter_conncontext { conn arg why } {&lt;br /&gt;
ns_log Notice &amp;quot;filter conn context&amp;quot;&lt;br /&gt;
return filter_ok&lt;br /&gt;
} ;# filter_noargs&lt;br /&gt;
&lt;br /&gt;
The conn (connection) argument is required for procedures registered by ns_register_filter if the procedure has 3 or more arguments (including why but not including conn). The conn argument is automatically filled with the connection information. The first argument following conn will always take the value supplied by ns_register_filter, if there is one, or an empty value. The why argument at the end is automatically filled with the type of filter requested. All other arguments must supply a default value. The following examples show the variations that can be used in this case:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; '''ns_register_filter''' ''postauth'' GET /threeargs threeargs aaa&lt;br /&gt;
'''ns_register_filter''' ''postauth'' GET /fourargs fourargs aaa bbb ccc&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
proc threeargs { conn context { greeble bork } why } {&lt;br /&gt;
...&lt;br /&gt;
} ;&lt;br /&gt;
&lt;br /&gt;
proc fourargs { conn context { greeble bork } {hoover quark} why } {&lt;br /&gt;
...&lt;br /&gt;
} ;&lt;br /&gt;
&lt;br /&gt;
When a GET of /threeargs is requested, the conn and why arguments will be filled automatically, the context argument will be assigned &amp;quot;aaa&amp;quot; and the greeble argument will be assigned the default value &amp;quot;bork&amp;quot;. When a GET of /fourargs is requested, the conn and why arguments will be filled automatically, the context argument will be assigned &amp;quot;aaa&amp;quot;, the greeble argument will be assigned &amp;quot;bbb&amp;quot;, and the hoover argument will be assigned the default value &amp;quot;quark&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== [http://aolserver.com/man/4.0/tcl/ns_filter.html#toc4 ns_register_trace:] ===&lt;br /&gt;
&lt;br /&gt;
; Register a Tcl trace script to a method and matching URL.&lt;br /&gt;
: (Note: This function is obsolete. Use '''ns_register_filter''' instead.)&lt;br /&gt;
&lt;br /&gt;
'''ns_register_trace''' registers a Tcl script as a trace for the specified method/URL combination. After the server handles the request for the specified method on an URL that matches the ''URLpattern'', it calls the trace script with the connection id and any arguments (args) specified. The ''URLpattern'' can contain standard string-matching characters. For example, these are valid URLpatterns:&lt;br /&gt;
&lt;br /&gt;
/employees/*.tcl /accounts/*/out&lt;br /&gt;
&lt;br /&gt;
Note '''ns_register_trace''' is similar to '''ns_register_proc''' except that the pattern-matching for the URL is performed differently. With '''ns_register_proc''', the specified URL is used to match that URL and any URL below it in the hierarchy. Wildcards such as &amp;quot;*&amp;quot; are meaningful only for the final part of the URL, such as /scripts/*.tcl. With '''ns_register_trace''', the ''URLpattern'' is used to match URLs as a string with standard string-matching characters. '''ns_register_proc''' results in a single match, whereas multiple ns_register_trace’s can be matched and will be called.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Additional notes:&lt;br /&gt;
&lt;br /&gt;
The manual page says ''&amp;quot;The URLpattern can contain standard string-matching characters&amp;quot;''. To be more precise the allowed matching characters are determined by [http://www.tcl.tk/man/tcl8.0/TclLib/StrMatch.htm Tcl_StrMatch] which in turn is determined by [http://www.tcl.tk/man/tcl8.0/TclCmd/string.htm#M10 TCL string match].&lt;br /&gt;
&lt;br /&gt;
[[Category:Core Tcl API]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_encoding&amp;diff=5828</id>
		<title>Ns register encoding</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_encoding&amp;diff=5828"/>
		<updated>2010-06-20T02:05:55Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''NAME'''&lt;br /&gt;
&lt;br /&gt;
: ns_register_encoding - Map method/URL combination to a specific charset encoding for decoding the request (new in AOLserver 4.5)&lt;br /&gt;
&lt;br /&gt;
'''SYNOPSIS'''&lt;br /&gt;
&lt;br /&gt;
: '''ns_register_encoding''' ''?-noinherit? method URL charset''&lt;br /&gt;
&lt;br /&gt;
'''DESCRIPTION'''&lt;br /&gt;
&lt;br /&gt;
: '''ns_register_encoding''' command enables mapping of method/URL combinations to specific charset encodings used to decode the request. If no mapping exists for a given method/URL, the server will use that defined for the virtual server or process wide by the ''urlcharset'' config setting. This setting defaults to NULL, or no encoding, thus assuming UTF-8 characters in the request data.&lt;br /&gt;
&lt;br /&gt;
: ''charset'' should be in the MIME format, not Tcl encoding format, i.e. iso-8859-1, not iso8859-1.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]] [[Category:Core Tcl API]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_encoding&amp;diff=5827</id>
		<title>Ns register encoding</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_register_encoding&amp;diff=5827"/>
		<updated>2010-06-20T02:03:26Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: Created page with ''''NAME'''  : ns_register_encoding - Map method/URL combination to a specific charset encoding for decoding the request (new in AOLserver 4.5)  '''SYNOPSIS'''  : '''ns_register_e…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''NAME'''&lt;br /&gt;
&lt;br /&gt;
: ns_register_encoding - Map method/URL combination to a specific charset encoding for decoding the request (new in AOLserver 4.5)&lt;br /&gt;
&lt;br /&gt;
'''SYNOPSIS'''&lt;br /&gt;
&lt;br /&gt;
: '''ns_register_encoding''' ''?-noinherit? method URL charset''&lt;br /&gt;
&lt;br /&gt;
'''DESCRIPTION'''&lt;br /&gt;
&lt;br /&gt;
: '''ns_register_encoding''' command enables mapping of method/URL combinations to specific charset encodings used to decode the request. If no mapping exists for a given method/URL, the server will use that defined for the virtual server or process wide by the ''urlcharset'' config setting. This setting defaults to NULL, or no encoding, thus assuming UTF-8 characters in the request data.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]] [[Category:Core Tcl API]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Tcl_API&amp;diff=5826</id>
		<title>Tcl API</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Tcl_API&amp;diff=5826"/>
		<updated>2010-06-20T01:56:33Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: /* Request processing commands */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Links to all of the Tcl commands provided by the AOLserver core &amp;quot;out of the box&amp;quot;.  To view a complete list of these commands in alphabetical order, try the [[:Category:Core Tcl API]] page.&lt;br /&gt;
&lt;br /&gt;
Like what you see here?  Want to try your hand at documenting a command, too?  Here's [[how to document the core Tcl API]].&lt;br /&gt;
&lt;br /&gt;
== ADP, Request and Response-oriented commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_adp_abort]], [[ns_adp_append]], [[ns_adp_argc]], [[ns_adp_argv]], [[ns_adp_bind_args]], [[ns_adp_break]], [[ns_adp_close]], [[ns_adp_ctl]], [[ns_adp_debug]], [[ns_adp_debuginit]], [[ns_adp_dir]], [[ns_adp_dump]], [[ns_adp_eval]], [[ns_adp_exception]], [[ns_adp_flush]], [[ns_adp_include]], [[ns_adp_mime]], [[ns_adp_mimetype]], [[ns_adp_parse]], [[ns_adp_puts]] ([[ns_puts]]), [[ns_adp_return]], [[ns_adp_safeeval]], [[ns_adp_stats]], [[ns_adp_stream]], [[ns_adp_tell]], [[ns_adp_trunc]]&lt;br /&gt;
&lt;br /&gt;
:'''Registered (fka fancy) ADP tags:'''&lt;br /&gt;
:[[ns_adp_registeradp]] (same as deprecated [[ns_adp_registertag]])&lt;br /&gt;
:[[ns_adp_registerproc]]&lt;br /&gt;
:[[ns_adp_registerscript]] (same as deprecated [[ns_register_adptag]]) &lt;br /&gt;
&lt;br /&gt;
:'''Request information and received content''':&lt;br /&gt;
: [[ns_conn]], [[ns_conncptofp]] (same as deprecated [[ns_writecontent]])&lt;br /&gt;
: [[ns_getform]], [[ns_getformfile]]&lt;br /&gt;
: [[ns_queryexists]], [[ns_queryget]], [[ns_querygetall]]&lt;br /&gt;
: [[ns_browsermatch]]&lt;br /&gt;
&lt;br /&gt;
:'''Standard response commands:'''&lt;br /&gt;
: [[ns_return]], [[ns_returnadminnotice]], [[ns_returnbadrequest]], [[ns_returnerror]], [[ns_returnfile]], [[ns_returnforbidden]], [[ns_returnfp]], [[ns_returnmoved]], [[ns_returnnotfound]], [[ns_returnnotice]], [[ns_returnok]], [[ns_returnredirect]], [[ns_returnunauthorized]]&lt;br /&gt;
&lt;br /&gt;
:'''More control over response:'''&lt;br /&gt;
: [[ns_setexpires]], [[ns_updateheader]], [[ns_respond]]&lt;br /&gt;
&lt;br /&gt;
:'''Manual response:'''&lt;br /&gt;
: [[ns_headers]], [[ns_startcontent]], [[ns_write]], [[ns_writefp]] / [[ns_connsendfp]] (deprecated)&lt;br /&gt;
&lt;br /&gt;
== Cache commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_cache]], [[ns_cache_flush]], [[ns_cache_keys]], [[ns_cache_names]], [[ns_cache_size]], [[ns_cache_stats]]&lt;br /&gt;
&lt;br /&gt;
== Concurrent programming commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_cond]], [[ns_critsec]], [[ns_event]], [[ns_job]], [[ns_kill]], [[ns_mutex]], [[ns_sema]], [[ns_thread]]&lt;br /&gt;
&lt;br /&gt;
== Custom data structures and variable manipulation commands ==&lt;br /&gt;
* TclX keyed lists:&lt;br /&gt;
&lt;br /&gt;
: [[keyldel]], [[keylget]], [[keylkeys]], [[keylset]]&lt;br /&gt;
* [[Thread-shared Variables]] (NSVs):&lt;br /&gt;
&lt;br /&gt;
: [[nsv_get]], [[nsv_exists]], [[nsv_set]], [[nsv_incr]], [[nsv_append]], [[nsv_lappend]], [[nsv_array]], [[nsv_unset]], [[nsv_names]]&lt;br /&gt;
* Sets and multisets:&lt;br /&gt;
&lt;br /&gt;
: [[ns_findset]], [[ns_set]]&lt;br /&gt;
* ???&lt;br /&gt;
&lt;br /&gt;
: [[ns_share]], [[ns_var]]&lt;br /&gt;
&lt;br /&gt;
== Database commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_buildsqldate]], [[ns_buildsqltime]], [[ns_buildsqltimestamp]], [[ns_db]], [[ns_dbquotename]], [[ns_dbquotevalue]], [[ns_localsqltimestamp]], [[ns_parsesqldate]], [[ns_parsesqltime]], [[ns_parsesqltimestamp]], [[ns_writecsv]]&lt;br /&gt;
&lt;br /&gt;
== DNS lookup commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_addrbyhost]], [[ns_hostbyaddr]]&lt;br /&gt;
&lt;br /&gt;
== File manipulation commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_chmod]], [[ns_cp]], [[ns_ftruncate]], [[ns_link]], [[ns_mkdir]], [[ns_mktemp]], [[ns_normalizepath]], [[ns_openexcl]], [[ns_purgefiles]], [[ns_rename]], [[ns_rmdir]], [[ns_rollfile]], [[ns_symlink]], [[ns_tmpnam]], [[ns_truncate]], [[ns_unlink]]&lt;br /&gt;
&lt;br /&gt;
== HTML manipulation commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_formvalueput]], [[ns_hrefs]], [[ns_htmlselect]], [[ns_quotehtml]], [[ns_striphtml]], [[ns_tagelement]], [[ns_tagelementset]]&lt;br /&gt;
&lt;br /&gt;
== HTTP commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_http]], [[ns_httpget]], [[ns_httpopen]], [[ns_httppost]]&lt;br /&gt;
&lt;br /&gt;
== Image manipulation commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_gifsize]], [[ns_jpegsize]]&lt;br /&gt;
&lt;br /&gt;
== Internationalization (I18N) support commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_charsets]], [[ns_choosecharset]], [[ns_cookiecharset]], [[ns_encodingforcharset]], [[ns_encodingfortype]], [[ns_formfieldcharset]], [[ns_setformencoding]] / [[ns_urlcharset]]&lt;br /&gt;
&lt;br /&gt;
== Logging commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_accesslog]], [[ns_log]], [[ns_logctl]], [[ns_logroll]]&lt;br /&gt;
&lt;br /&gt;
== Request authorization commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_checkurl]], [[ns_requestauthorize]]&lt;br /&gt;
&lt;br /&gt;
== Request processing commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_register_adp]], [[ns_register_cgi]], [[ns_register_encoding]], [[ns_register_fastpath]], [[ns_register_filter]], [[ns_register_proc]], [[ns_register_trace]], [[ns_unregister_adp]], [[ns_unregister_proc]]&lt;br /&gt;
&lt;br /&gt;
== Scheduling commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_after]], [[ns_atclose]], [[ns_atexit]], [[ns_atshutdown]], [[ns_atsignal]], [[ns_cancel]], [[ns_pause]], [[ns_resume]], [[ns_schedule_proc]], [[ns_schedule_daily]], [[ns_schedule_weekly]], [[ns_shutdown]], [[ns_unschedule_proc]]&lt;br /&gt;
&lt;br /&gt;
== Server configuration commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_config]], [[ns_configsection]], [[ns_configsections]], [[ns_library]], [[ns_limits]], [[ns_modulepath]], [[ns_param]], [[ns_pools]], [[ns_section]]&lt;br /&gt;
&lt;br /&gt;
== Server introspection commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_driver]], [[ns_env]], [[ns_info]], [[ns_server]], [[ns_stats]] (3.x only, defunct in 4.0+)&lt;br /&gt;
&lt;br /&gt;
== Socket I/O commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_sock]], [[ns_sockaccept]], [[ns_sockblocking]], [[ns_sockcallback]], [[ns_sockcheck]], [[ns_sockclose]], [[ns_sockdup]], [[ns_sockerrno]], [[ns_socketpair]], [[ns_sockioctl]], [[ns_socklisten]], [[ns_socklistencallback]], [[ns_socknbclose]], [[ns_socknonblocking]], [[ns_socknread]], [[ns_sockopen]], [[ns_sockpair]], [[ns_sockreadwait]], [[ns_sockselect]], [[ns_socksend]], [[ns_sockstrerror]]&lt;br /&gt;
&lt;br /&gt;
== Tcl channel management commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_chan]], [[ns_cleanupchans]], [[ns_getchannels]]&lt;br /&gt;
&lt;br /&gt;
== Tcl interpreter management commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_cleanup]], [[ns_eval]], [[ns_interp_ctl]] (4.5+) / [[ns_ictl]] (4.0), [[ns_init]], [[ns_loop_ctl]], [[ns_markfordelete]], [[ns_reinit]]&lt;br /&gt;
&lt;br /&gt;
== Time commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_fmttime]], [[ns_gmtime]], [[ns_httptime]], [[ns_localtime]], [[ns_parsehttptime]], [[ns_parsetime]], [[ns_time]]&lt;br /&gt;
   &lt;br /&gt;
== Uncategorized ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_cpfp]], [[ns_crypt]], [[ns_getcsv]], [[ns_geturl]], [[ns_guesstype]], [[ns_isformcached]], [[ns_issmallint]], [[ns_paren]], [[ns_parseheader]], [[ns_parsequery]], [[ns_rand]], [[ns_resetcachedform]], [[ns_sendmail]], [[ns_sleep]], [[ns_sourceproc]], [[ns_url2file]], [[ns_urldecode]], [[ns_urlencode]], [[ns_uudecode]], [[ns_uuencode]], [[ns_zlib]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Tcl_API&amp;diff=5825</id>
		<title>Tcl API</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Tcl_API&amp;diff=5825"/>
		<updated>2010-06-20T01:55:39Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: /* Uncategorized */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Links to all of the Tcl commands provided by the AOLserver core &amp;quot;out of the box&amp;quot;.  To view a complete list of these commands in alphabetical order, try the [[:Category:Core Tcl API]] page.&lt;br /&gt;
&lt;br /&gt;
Like what you see here?  Want to try your hand at documenting a command, too?  Here's [[how to document the core Tcl API]].&lt;br /&gt;
&lt;br /&gt;
== ADP, Request and Response-oriented commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_adp_abort]], [[ns_adp_append]], [[ns_adp_argc]], [[ns_adp_argv]], [[ns_adp_bind_args]], [[ns_adp_break]], [[ns_adp_close]], [[ns_adp_ctl]], [[ns_adp_debug]], [[ns_adp_debuginit]], [[ns_adp_dir]], [[ns_adp_dump]], [[ns_adp_eval]], [[ns_adp_exception]], [[ns_adp_flush]], [[ns_adp_include]], [[ns_adp_mime]], [[ns_adp_mimetype]], [[ns_adp_parse]], [[ns_adp_puts]] ([[ns_puts]]), [[ns_adp_return]], [[ns_adp_safeeval]], [[ns_adp_stats]], [[ns_adp_stream]], [[ns_adp_tell]], [[ns_adp_trunc]]&lt;br /&gt;
&lt;br /&gt;
:'''Registered (fka fancy) ADP tags:'''&lt;br /&gt;
:[[ns_adp_registeradp]] (same as deprecated [[ns_adp_registertag]])&lt;br /&gt;
:[[ns_adp_registerproc]]&lt;br /&gt;
:[[ns_adp_registerscript]] (same as deprecated [[ns_register_adptag]]) &lt;br /&gt;
&lt;br /&gt;
:'''Request information and received content''':&lt;br /&gt;
: [[ns_conn]], [[ns_conncptofp]] (same as deprecated [[ns_writecontent]])&lt;br /&gt;
: [[ns_getform]], [[ns_getformfile]]&lt;br /&gt;
: [[ns_queryexists]], [[ns_queryget]], [[ns_querygetall]]&lt;br /&gt;
: [[ns_browsermatch]]&lt;br /&gt;
&lt;br /&gt;
:'''Standard response commands:'''&lt;br /&gt;
: [[ns_return]], [[ns_returnadminnotice]], [[ns_returnbadrequest]], [[ns_returnerror]], [[ns_returnfile]], [[ns_returnforbidden]], [[ns_returnfp]], [[ns_returnmoved]], [[ns_returnnotfound]], [[ns_returnnotice]], [[ns_returnok]], [[ns_returnredirect]], [[ns_returnunauthorized]]&lt;br /&gt;
&lt;br /&gt;
:'''More control over response:'''&lt;br /&gt;
: [[ns_setexpires]], [[ns_updateheader]], [[ns_respond]]&lt;br /&gt;
&lt;br /&gt;
:'''Manual response:'''&lt;br /&gt;
: [[ns_headers]], [[ns_startcontent]], [[ns_write]], [[ns_writefp]] / [[ns_connsendfp]] (deprecated)&lt;br /&gt;
&lt;br /&gt;
== Cache commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_cache]], [[ns_cache_flush]], [[ns_cache_keys]], [[ns_cache_names]], [[ns_cache_size]], [[ns_cache_stats]]&lt;br /&gt;
&lt;br /&gt;
== Concurrent programming commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_cond]], [[ns_critsec]], [[ns_event]], [[ns_job]], [[ns_kill]], [[ns_mutex]], [[ns_sema]], [[ns_thread]]&lt;br /&gt;
&lt;br /&gt;
== Custom data structures and variable manipulation commands ==&lt;br /&gt;
* TclX keyed lists:&lt;br /&gt;
&lt;br /&gt;
: [[keyldel]], [[keylget]], [[keylkeys]], [[keylset]]&lt;br /&gt;
* [[Thread-shared Variables]] (NSVs):&lt;br /&gt;
&lt;br /&gt;
: [[nsv_get]], [[nsv_exists]], [[nsv_set]], [[nsv_incr]], [[nsv_append]], [[nsv_lappend]], [[nsv_array]], [[nsv_unset]], [[nsv_names]]&lt;br /&gt;
* Sets and multisets:&lt;br /&gt;
&lt;br /&gt;
: [[ns_findset]], [[ns_set]]&lt;br /&gt;
* ???&lt;br /&gt;
&lt;br /&gt;
: [[ns_share]], [[ns_var]]&lt;br /&gt;
&lt;br /&gt;
== Database commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_buildsqldate]], [[ns_buildsqltime]], [[ns_buildsqltimestamp]], [[ns_db]], [[ns_dbquotename]], [[ns_dbquotevalue]], [[ns_localsqltimestamp]], [[ns_parsesqldate]], [[ns_parsesqltime]], [[ns_parsesqltimestamp]], [[ns_writecsv]]&lt;br /&gt;
&lt;br /&gt;
== DNS lookup commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_addrbyhost]], [[ns_hostbyaddr]]&lt;br /&gt;
&lt;br /&gt;
== File manipulation commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_chmod]], [[ns_cp]], [[ns_ftruncate]], [[ns_link]], [[ns_mkdir]], [[ns_mktemp]], [[ns_normalizepath]], [[ns_openexcl]], [[ns_purgefiles]], [[ns_rename]], [[ns_rmdir]], [[ns_rollfile]], [[ns_symlink]], [[ns_tmpnam]], [[ns_truncate]], [[ns_unlink]]&lt;br /&gt;
&lt;br /&gt;
== HTML manipulation commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_formvalueput]], [[ns_hrefs]], [[ns_htmlselect]], [[ns_quotehtml]], [[ns_striphtml]], [[ns_tagelement]], [[ns_tagelementset]]&lt;br /&gt;
&lt;br /&gt;
== HTTP commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_http]], [[ns_httpget]], [[ns_httpopen]], [[ns_httppost]]&lt;br /&gt;
&lt;br /&gt;
== Image manipulation commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_gifsize]], [[ns_jpegsize]]&lt;br /&gt;
&lt;br /&gt;
== Internationalization (I18N) support commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_charsets]], [[ns_choosecharset]], [[ns_cookiecharset]], [[ns_encodingforcharset]], [[ns_encodingfortype]], [[ns_formfieldcharset]], [[ns_setformencoding]] / [[ns_urlcharset]]&lt;br /&gt;
&lt;br /&gt;
== Logging commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_accesslog]], [[ns_log]], [[ns_logctl]], [[ns_logroll]]&lt;br /&gt;
&lt;br /&gt;
== Request authorization commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_checkurl]], [[ns_requestauthorize]]&lt;br /&gt;
&lt;br /&gt;
== Request processing commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_register_adp]], [[ns_register_cgi]], [[ns_register_fastpath]], [[ns_register_filter]], [[ns_register_proc]], [[ns_register_trace]], [[ns_unregister_adp]], [[ns_unregister_proc]]&lt;br /&gt;
&lt;br /&gt;
== Scheduling commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_after]], [[ns_atclose]], [[ns_atexit]], [[ns_atshutdown]], [[ns_atsignal]], [[ns_cancel]], [[ns_pause]], [[ns_resume]], [[ns_schedule_proc]], [[ns_schedule_daily]], [[ns_schedule_weekly]], [[ns_shutdown]], [[ns_unschedule_proc]]&lt;br /&gt;
&lt;br /&gt;
== Server configuration commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_config]], [[ns_configsection]], [[ns_configsections]], [[ns_library]], [[ns_limits]], [[ns_modulepath]], [[ns_param]], [[ns_pools]], [[ns_section]]&lt;br /&gt;
&lt;br /&gt;
== Server introspection commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_driver]], [[ns_env]], [[ns_info]], [[ns_server]], [[ns_stats]] (3.x only, defunct in 4.0+)&lt;br /&gt;
&lt;br /&gt;
== Socket I/O commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_sock]], [[ns_sockaccept]], [[ns_sockblocking]], [[ns_sockcallback]], [[ns_sockcheck]], [[ns_sockclose]], [[ns_sockdup]], [[ns_sockerrno]], [[ns_socketpair]], [[ns_sockioctl]], [[ns_socklisten]], [[ns_socklistencallback]], [[ns_socknbclose]], [[ns_socknonblocking]], [[ns_socknread]], [[ns_sockopen]], [[ns_sockpair]], [[ns_sockreadwait]], [[ns_sockselect]], [[ns_socksend]], [[ns_sockstrerror]]&lt;br /&gt;
&lt;br /&gt;
== Tcl channel management commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_chan]], [[ns_cleanupchans]], [[ns_getchannels]]&lt;br /&gt;
&lt;br /&gt;
== Tcl interpreter management commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_cleanup]], [[ns_eval]], [[ns_interp_ctl]] (4.5+) / [[ns_ictl]] (4.0), [[ns_init]], [[ns_loop_ctl]], [[ns_markfordelete]], [[ns_reinit]]&lt;br /&gt;
&lt;br /&gt;
== Time commands ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_fmttime]], [[ns_gmtime]], [[ns_httptime]], [[ns_localtime]], [[ns_parsehttptime]], [[ns_parsetime]], [[ns_time]]&lt;br /&gt;
   &lt;br /&gt;
== Uncategorized ==&lt;br /&gt;
&lt;br /&gt;
: [[ns_cpfp]], [[ns_crypt]], [[ns_getcsv]], [[ns_geturl]], [[ns_guesstype]], [[ns_isformcached]], [[ns_issmallint]], [[ns_paren]], [[ns_parseheader]], [[ns_parsequery]], [[ns_rand]], [[ns_resetcachedform]], [[ns_sendmail]], [[ns_sleep]], [[ns_sourceproc]], [[ns_url2file]], [[ns_urldecode]], [[ns_urlencode]], [[ns_uudecode]], [[ns_uuencode]], [[ns_zlib]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_zlib&amp;diff=5824</id>
		<title>Ns zlib</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_zlib&amp;diff=5824"/>
		<updated>2010-06-20T01:52:43Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''NAME'''&lt;br /&gt;
&lt;br /&gt;
ns_zlib - Zlib compression support &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''SYNOPSIS'''&lt;br /&gt;
&lt;br /&gt;
'''ns_zlib compress''' ''string''&lt;br /&gt;
&lt;br /&gt;
'''ns_zlib gunzip''' ''file''&lt;br /&gt;
&lt;br /&gt;
'''ns_zlib gzip''' ''string''&lt;br /&gt;
&lt;br /&gt;
'''ns_zlib gzipfile''' ''file''&lt;br /&gt;
&lt;br /&gt;
'''ns_zlib uncompress''' ''string''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''DESCRIPTION'''&lt;br /&gt;
&lt;br /&gt;
The '''ns_zlib''' command enables compressing and uncompressing of strings or files.  The command is available if the ''nszlib.so'' module is loaded into AOLserver or the ''libnszlib.so'', ''nszlib.dll'', or ''libnszlib.dylib'' dynamic library is loaded using the '''load''' command in a suitable ''tclsh'' such as ''nstclsh''.  &lt;br /&gt;
*'''ns_zlib compress''' ''string''&lt;br /&gt;
: This command compresses the given string and returns a Tcl byte array object with the compressed data.  &lt;br /&gt;
*'''ns_zlib gunzip''' ''file''&lt;br /&gt;
: This command uncompresses the contents of the given gzipped file and returns a string as the result.  &lt;br /&gt;
*'''ns_zlib gzipfile''' ''file''&lt;br /&gt;
: This command is similar to the '''gzip''' shell routines, compressing the given file into a new file with the ''.gz'' extension.  If successful, the original uncompressed file is deleted.  &lt;br /&gt;
*'''ns_zlib uncompress''' ''bytearray''&lt;br /&gt;
: This command takes a byte array object which includes compressed data and returns an uncompressed string object.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''EXAMPLES'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: The following examples demonstrate compressing and uncompressing a string;  &lt;br /&gt;
    &amp;lt;pre&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    # Compress Tcl string&lt;br /&gt;
    set test &amp;quot;This is test string&amp;quot;&lt;br /&gt;
    set data [ns_zlib compress $test]&lt;br /&gt;
    set test [ns_zlib uncompress $data]&lt;br /&gt;
    #--&amp;gt; returns &amp;quot;This is test string&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    # Compress the string into gzip format&lt;br /&gt;
    set gzip [ns_zlib gzip $test]&lt;br /&gt;
    &lt;br /&gt;
    # Save as gzip file&lt;br /&gt;
    set fd [open /tmp/test.gz w]&lt;br /&gt;
    fconfigure $fd -translation binary -encoding binary&lt;br /&gt;
    puts -nonewline $fd $gzip&lt;br /&gt;
    close $fd&lt;br /&gt;
    &lt;br /&gt;
    # Uncompress gzipped file&lt;br /&gt;
    set test [ns_zlib gunzip /tmp/test.gz]&lt;br /&gt;
    #--&amp;gt; returns &amp;quot;This is test string&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_zlib&amp;diff=5823</id>
		<title>Ns zlib</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_zlib&amp;diff=5823"/>
		<updated>2010-06-20T01:50:47Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: Created page with ''''NAME'''  ns_zlib - Zlib compression support    '''SYNOPSIS'''  '''ns_zlib compress''' ''string'' '''ns_zlib gunzip''' ''file'' '''ns_zlib gzip''' ''string'' '''ns_zlib gzipfil…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''NAME'''&lt;br /&gt;
&lt;br /&gt;
ns_zlib - Zlib compression support &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''SYNOPSIS'''&lt;br /&gt;
&lt;br /&gt;
'''ns_zlib compress''' ''string''&lt;br /&gt;
'''ns_zlib gunzip''' ''file''&lt;br /&gt;
'''ns_zlib gzip''' ''string''&lt;br /&gt;
'''ns_zlib gzipfile''' ''file''&lt;br /&gt;
'''ns_zlib uncompress''' ''string''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''DESCRIPTION'''&lt;br /&gt;
&lt;br /&gt;
The '''ns_zlib''' command enables compressing and uncompressing of strings or files.  The command is available if the ''nszlib.so'' module is loaded into AOLserver or the ''libnszlib.so'', ''nszlib.dll'', or ''libnszlib.dylib'' dynamic library is loaded using the '''load''' command in a suitable ''tclsh'' such as ''nstclsh''.  &lt;br /&gt;
*'''ns_zlib compress''' ''string''&lt;br /&gt;
: This command compresses the given string and returns a Tcl byte array object with the compressed data.  &lt;br /&gt;
*'''ns_zlib gunzip''' ''file''&lt;br /&gt;
: This command uncompresses the contents of the given gzipped file and returns a string as the result.  &lt;br /&gt;
*'''ns_zlib gzipfile''' ''file''&lt;br /&gt;
: This command is similar to the '''gzip''' shell routines, compressing the given file into a new file with the ''.gz'' extension.  If successful, the original uncompressed file is deleted.  &lt;br /&gt;
*'''ns_zlib uncompress''' ''bytearray''&lt;br /&gt;
: This command takes a byte array object which includes compressed data and returns an uncompressed string object.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''EXAMPLES'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: The following examples demonstrate compressing and uncompressing a string;  &lt;br /&gt;
    &amp;lt;pre&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    # Compress Tcl string&lt;br /&gt;
    set test &amp;quot;This is test string&amp;quot;&lt;br /&gt;
    set data [ns_zlib compress $test]&lt;br /&gt;
    set test [ns_zlib uncompress $data]&lt;br /&gt;
    ''--&amp;gt; returns &amp;quot;This is test string&amp;quot;''&lt;br /&gt;
    &lt;br /&gt;
    # Compress the string into gzip format&lt;br /&gt;
    set gzip [ns_zlib gzip $test]&lt;br /&gt;
    &lt;br /&gt;
    # Save as gzip file&lt;br /&gt;
    set fd [open /tmp/test.gz w]&lt;br /&gt;
    fconfigure $fd -translation binary -encoding binary&lt;br /&gt;
    puts -nonewline $fd $gzip&lt;br /&gt;
    close $fd&lt;br /&gt;
    &lt;br /&gt;
    # Uncompress gzipped file&lt;br /&gt;
    set test [ns_zlib gunzip /tmp/test.gz]&lt;br /&gt;
    ''--&amp;gt; returns &amp;quot;This is test string&amp;quot;''&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=AOLserver_Wiki&amp;diff=5821</id>
		<title>AOLserver Wiki</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=AOLserver_Wiki&amp;diff=5821"/>
		<updated>2010-06-19T04:09:08Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: /* Related Links: */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=What%27s_new_in_4.5&amp;diff=5820</id>
		<title>What's new in 4.5</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=What%27s_new_in_4.5&amp;diff=5820"/>
		<updated>2010-06-19T01:37:28Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a fairly comprehensive list of new features and changes in AOLserver 4.5 and 4.5.1 (compared to 4.0).  If you know of anything that is missing, please add it.&lt;br /&gt;
&lt;br /&gt;
=== Connection Management: ===&lt;br /&gt;
&lt;br /&gt;
These two commands can be used together to map slow running requests to a specific pool and to set limits to avoid overload.&lt;br /&gt;
&lt;br /&gt;
* New '''[[ns_pools]]''' command to map method/URL's to specific thread pools.&lt;br /&gt;
* New '''[[ns_limits]]''' command  control the number of threads executing and/or waiting for execution by method/URL.&lt;br /&gt;
*'''Note:''' The new scheme does not pick up connection thread pool configurations from earlier versions of AOLServer. Please see the new example configuration files, and the documentation for [[ns_pools]] and [[ns_limits]], for instructions in upgrading your configuration.  &lt;br /&gt;
** As of 1 August 2007, the HEAD revision contains &amp;quot;pools.tcl&amp;quot;, which will handle many pre-4.5 configurations.&lt;br /&gt;
** There are known issues when using this feature in conjunction with virtual servers; see the SourceForge bug list (and development mailing list archive) for details.&lt;br /&gt;
&lt;br /&gt;
=== I/O Features: ===&lt;br /&gt;
&lt;br /&gt;
* New '''Ns_QueueWait''' API to enable event-driven callbacks in the driver thread before dispatching to pools for processing.&lt;br /&gt;
&lt;br /&gt;
:The allows drivers to augment data received from the client (headers, request, content) with additional data fetched over the network (likely stored in the new Ns_Cls &amp;quot;connection local storage&amp;quot; API's) before dispatching to the connection threads.  An example would be to add certain personalization data received via a web service. The rationale here is that I/O events are cheap so do those upfront instead of having expensive connection threads burdened with wasteful blocking I/O.  This is a somewhat obscure and technical interface.&lt;br /&gt;
&lt;br /&gt;
* Added ability to manage larger file uploads by spooling to a temporary file (currenty not for Windows).&lt;br /&gt;
&lt;br /&gt;
* New '''[[nsproxy]]''' module which provides the '''ns_proxy''' command which enables sending Tcl scripts to a proxy process connected via a pipe. The proxy includes core Tcl commands as well as AOLserver commands from the libnsd library. Evaluating scripts in a proxy process can be used to isolate and/or timeout thread-unsafe or otherwise unsafe 3rd party code.&lt;br /&gt;
&lt;br /&gt;
=== ADP Improvements: ===&lt;br /&gt;
&lt;br /&gt;
* Added a new execution caching technique at the '''[[ns_adp_include]]''' level which allows you to save the results of execution of an included ADP and includes below that for reuse on subsequent connections up to a specified time.&lt;br /&gt;
* Added '''singlescript''' config option which turns ADP pages into a single script enabling syntax such as &amp;quot;&amp;lt;% foreach e $list { %&amp;gt; element &amp;lt;%= $e %&amp;gt; here &amp;lt;% } %&amp;gt;&amp;quot;.&lt;br /&gt;
* Added support for nested adp tags, i.e. you can now do  &amp;lt;% ns_adp_puts [ns_adp_eval {&amp;lt;% ... %&amp;gt;}] %&amp;gt; or use &amp;lt;% %&amp;gt; script within the body of a fancy tag.  Note that there is a known issue in that only a single inner instance of an adp tag is supported - see [http://sourceforge.net/tracker/?func=detail&amp;amp;aid=2958550&amp;amp;group_id=3152&amp;amp;atid=103152 Bug #2958550].&lt;br /&gt;
* Introduced a better command name to clear long-standing confusion between the previous registertag commands: '''[[ns_adp_registerscript]]''' instead of ns_register_adptag.&lt;br /&gt;
* Added '''[[ns_adp_registerproc]]''' which is similar to ns_adp_registerscript but the procedure receives individual arguments instead of an ns_set.&lt;br /&gt;
* Added output buffer improvements via new Ns_ConnFlush.  See '''[[ns_adp_close]]''' and '''[[ns_adp_flush]]'''&lt;br /&gt;
* Added automatic UTF-8 to output charset encoding.&lt;br /&gt;
* Added gzip output compression.&lt;br /&gt;
* Added streaming output in chunked-encoding format instead of the previous &amp;quot;response with no length&amp;quot; HTTP/1.0 method.&lt;br /&gt;
* Enhanced ADP error handling and reporting.&lt;br /&gt;
* Added ability to trace ADP pages.  Trace output is written to the server log.  See '''[[ns_adp_ctl]]''', which is a new command for configuring the ADP execution environment at runtime.&lt;br /&gt;
&lt;br /&gt;
=== Other Improvements: ===&lt;br /&gt;
&lt;br /&gt;
* New '''Ns_TclRegisterTrace''' API to enable callbacks at key state transition points in a much more natural way.  The [[ns_ictl]] command, which now has a second and better name that should be used going forward - '''[[ns_interp_ctl]]''', has been updated to support script-level traces.&lt;br /&gt;
* New '''Ns_Task''' API designed to replace the old Ns_SockCallback API which didn't do a very good job at managing timeouts along with I/O events.&lt;br /&gt;
* New '''[[ns_returnmoved]]''' command to return 301 http status code and redirect to a new URL.&lt;br /&gt;
* New '''[[ns_internalredirect]]''' command to restart connection processing with a new URL.&lt;br /&gt;
* 4.5.1 - Added '''ns_conn channel''' and '''ns_conn contentsentlength''' subcommands to [[ns_conn]] to allow raw communication via Tcl I/O to the remote client.&lt;br /&gt;
* New '''[[ns_cache]]''' command based on ideas from the [[nscache]] module.   This is semi-backward-compatible with the ns_cache module (differences are described in detail in '''[[ns_cache]]''').&lt;br /&gt;
* New '''[[ns_loop_ctl]]''' command to monitor and manage ''for'', ''while'', and ''foreach'' loops.&lt;br /&gt;
* Added '''ns_ictl once''' subcommand to [[ns_ictl]] / [[ns_interp_ctl]] command to execute a script exactly once for a virtual server (i.e. at startup).&lt;br /&gt;
* Added '''ns_ictl package''' subcommand to [[ns_ictl]] / [[ns_interp_ctl]] command to handle loading of Tcl packages.&lt;br /&gt;
* Added '''ns_ictl cancel''' subcommand  to [[ns_ictl]] / [[ns_interp_ctl]] command to provide the ability to sendr async-cancel messages to any interpter listed in '''ns_ictl threads''' (another new subcommand)&lt;br /&gt;
* New '''[[ns_register_fastpath]]''' command to re-enable fastpath after a previous call to '''ns_register_proc'''.&lt;br /&gt;
* New '''[[ns_register_encoding]]''' command to enable mapping of method/URL combinations to specific charset encodings used to decode the request.&lt;br /&gt;
* 4.5.1 - New '''[[ns_register_cgi]]''' command to dynamically register a CGI executable to a url.&lt;br /&gt;
* New '''[[ns_driver]]''' command to get some stats on socket drivers.&lt;br /&gt;
* [[nszlib]] module is now integrated into the core and provides for on-the-fly gzip compression and other gzip facilities in '''[[ns_zlib]]'''&lt;br /&gt;
* -all switch added to '''[[ns_addrbyhost]]''' command.&lt;br /&gt;
* Added ability to access more AOLserver functionality from a tclsh (nsv_*, ns_thread, etc).&lt;br /&gt;
* Stack checking has returned.  In a multi-threaded application like AOLserver, stack checking is important for detecting buffer overruns and deep call trees blowing your thread stack, etc.&lt;br /&gt;
* More detailed information when logging uncaught Tcl errors.  Especially for connection threads, details of the HTTP request are logged to make diagnosing the root cause of errors easier.&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=What%27s_new_in_4.5&amp;diff=5819</id>
		<title>What's new in 4.5</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=What%27s_new_in_4.5&amp;diff=5819"/>
		<updated>2010-06-19T01:28:52Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a fairly comprehensive list of new features and changes in AOLserver 4.5 and 4.5.1 (compared to 4.0).  If you know of anything that is missing, please add it.&lt;br /&gt;
&lt;br /&gt;
=== Connection Management: ===&lt;br /&gt;
&lt;br /&gt;
These two commands can be used together to map slow running requests to a specific pool and to set limits to avoid overload.&lt;br /&gt;
&lt;br /&gt;
* New '''[[ns_pools]]''' command to map method/URL's to specific thread pools.&lt;br /&gt;
* New '''[[ns_limits]]''' command  control the number of threads executing and/or waiting for execution by method/URL.&lt;br /&gt;
*'''Note:''' The new scheme does not pick up connection thread pool configurations from earlier versions of AOLServer. Please see the new example configuration files, and the documentation for [[ns_pools]] and [[ns_limits]], for instructions in upgrading your configuration.  &lt;br /&gt;
** As of 1 August 2007, the HEAD revision contains &amp;quot;pools.tcl&amp;quot;, which will handle many pre-4.5 configurations.&lt;br /&gt;
** There are known issues when using this feature in conjunction with virtual servers; see the SourceForge bug list (and development mailing list archive) for details.&lt;br /&gt;
&lt;br /&gt;
=== I/O Features: ===&lt;br /&gt;
&lt;br /&gt;
* New '''Ns_QueueWait''' API to enable event-driven callbacks in the driver thread before dispatching to pools for processing.&lt;br /&gt;
&lt;br /&gt;
:The allows drivers to augment data received from the client (headers, request, content) with additional data fetched over the network (likely stored in the new Ns_Cls &amp;quot;connection local storage&amp;quot; API's) before dispatching to the connection threads.  An example would be to add certain personalization data received via a web service. The rationale here is that I/O events are cheap so do those upfront instead of having expensive connection threads burdened with wasteful blocking I/O.  This is a somewhat obscure and technical interface.&lt;br /&gt;
&lt;br /&gt;
* Added ability to manage larger file uploads by spooling to a temporary file (currenty not for Windows).&lt;br /&gt;
&lt;br /&gt;
* New '''[[nsproxy]]''' module which provides the '''ns_proxy''' command which enables sending Tcl scripts to a proxy process connected via a pipe. The proxy includes core Tcl commands as well as AOLserver commands from the libnsd library. Evaluating scripts in a proxy process can be used to isolate and/or timeout thread-unsafe or otherwise unsafe 3rd party code.&lt;br /&gt;
&lt;br /&gt;
=== ADP Improvements: ===&lt;br /&gt;
&lt;br /&gt;
* Added a new execution caching technique at the '''[[ns_adp_include]]''' level which allows you to save the results of execution of an included ADP and includes below that for reuse on subsequent connections up to a specified time.&lt;br /&gt;
* Added '''singlescript''' config option which turns ADP pages into a single script enabling syntax such as &amp;quot;&amp;lt;% foreach e $list { %&amp;gt; element &amp;lt;%= $e %&amp;gt; here &amp;lt;% } %&amp;gt;&amp;quot;.&lt;br /&gt;
* Added support for nested adp tags, i.e. you can now do  &amp;lt;% ns_adp_puts [ns_adp_eval {&amp;lt;% ... %&amp;gt;}] %&amp;gt; or use &amp;lt;% %&amp;gt; script within the body of a fancy tag.  Note that there is a known issue in that only a single inner instance of an adp tag is supported - see [http://sourceforge.net/tracker/?func=detail&amp;amp;aid=2958550&amp;amp;group_id=3152&amp;amp;atid=103152 Bug #2958550].&lt;br /&gt;
* Introduced a better command name to clear long-standing confusion between the previous registertag commands: '''[[ns_adp_registerscript]]''' instead of ns_register_adptag.&lt;br /&gt;
* Added '''[[ns_adp_registerproc]]''' which is similar to ns_adp_registerscript but the procedure receives individual arguments instead of an ns_set.&lt;br /&gt;
* Added output buffer improvements via new Ns_ConnFlush.  See '''[[ns_adp_close]]''' and '''[[ns_adp_flush]]'''&lt;br /&gt;
* Added automatic UTF-8 to output charset encoding.&lt;br /&gt;
* Added gzip output compression.&lt;br /&gt;
* Added streaming output in chunked-encoding format instead of the previous &amp;quot;response with no length&amp;quot; HTTP/1.0 method.&lt;br /&gt;
* Enhanced ADP error handling and reporting.&lt;br /&gt;
* Added ability to trace ADP pages.  Trace output is written to the server log.  See '''[[ns_adp_ctl]]''', which is a new command for configuring the ADP execution environment at runtime.&lt;br /&gt;
&lt;br /&gt;
=== Other Improvements: ===&lt;br /&gt;
&lt;br /&gt;
* New '''Ns_TclRegisterTrace''' API to enable callbacks at key state transition points in a much more natural way.  The [[ns_ictl]] command, which now has a second and better name that should be used going forward - '''[[ns_interp_ctl]]''', has been updated to support script-level traces.&lt;br /&gt;
* New '''Ns_Task''' API designed to replace the old Ns_SockCallback API which didn't do a very good job at managing timeouts along with I/O events.&lt;br /&gt;
* New '''[[ns_returnmoved]]''' command to return 301 http status code and redirect to a new URL.&lt;br /&gt;
* New '''[[ns_internalredirect]]''' command to restart connection processing with a new URL.&lt;br /&gt;
* 4.5.1 - Added '''ns_conn channel''' and '''ns_conn contentsentlength''' subcommands to [[ns_conn]] to allow raw communication via Tcl I/O to the remote client.&lt;br /&gt;
* New '''[[ns_cache]]''' command based on ideas from the [[nscache]] module.   This is semi-backward-compatible with the ns_cache module (differences are described in detail in '''[[ns_cache]]''').&lt;br /&gt;
* New '''[[ns_loop_ctl]]''' command to monitor and manage ''for'', ''while'', and ''foreach'' loops.&lt;br /&gt;
* Added '''ns_ictl once''' subcommand to [[ns_ictl]] / [[ns_interp_ctl]] command to execute a script exactly once for a virtual server (i.e. at startup).&lt;br /&gt;
* Added '''ns_ictl package''' subcommand to [[ns_ictl]] / [[ns_interp_ctl]] command to handle loading of Tcl packages.&lt;br /&gt;
* Added '''ns_ictl cancel''' subcommand  to [[ns_ictl]] / [[ns_interp_ctl]] command to provide the ability to sendr async-cancel messages to any interpter listed in '''ns_ictl threads''' (another new subcommand)&lt;br /&gt;
* New '''[[ns_register_fastpath]]''' command to re-enable fastpath after a previous call to '''ns_register_proc'''.&lt;br /&gt;
* New '''[[ns_register_encoding]]''' command to enable mapping of method/URL combinations to specific charset encodings used to decode the request.&lt;br /&gt;
* 4.5.1 - New '''[[ns_register_cgi]]''' command to dynamically register a CGI executable to a url.&lt;br /&gt;
* New '''[[ns_driver]]''' command to get some stats on socket drivers.&lt;br /&gt;
* [[nszlib]] module is now integrated into the core and provides for on-the-fly gzip compression and other gzip facilities in '''[[ns_gzip]]'''&lt;br /&gt;
* -all switch added to '''[[ns_addrbyhost]]''' command.&lt;br /&gt;
* Added ability to access more AOLserver functionality from a tclsh (nsv_*, ns_thread, etc).&lt;br /&gt;
* Stack checking has returned.  In a multi-threaded application like AOLserver, stack checking is important for detecting buffer overruns and deep call trees blowing your thread stack, etc.&lt;br /&gt;
* More detailed information when logging uncaught Tcl errors.  Especially for connection threads, details of the HTTP request are logged to make diagnosing the root cause of errors easier.&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=What%27s_new_in_4.5&amp;diff=5818</id>
		<title>What's new in 4.5</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=What%27s_new_in_4.5&amp;diff=5818"/>
		<updated>2010-06-19T01:25:59Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a fairly comprehensive list of new features and changes in AOLserver 4.5 and 4.5.1 (compared to 4.0).  If you know of anything that is missing, please add it.&lt;br /&gt;
&lt;br /&gt;
=== Connection Management: ===&lt;br /&gt;
&lt;br /&gt;
These two commands can be used together to map slow running requests to a specific pool and to set limits to avoid overload.&lt;br /&gt;
&lt;br /&gt;
* New '''ns_pools''' command to map method/URL's to specific thread pools.&lt;br /&gt;
* New '''ns_limits''' command  control the number of threads executing and/or waiting for execution by method/URL.&lt;br /&gt;
*'''Note:''' The new scheme does not pick up connection thread pool configurations from earlier versions of AOLServer. Please see the new example configuration files, and the documentation for [[ns_pools]] and [[ns_limits]], for instructions in upgrading your configuration.  &lt;br /&gt;
** As of 1 August 2007, the HEAD revision contains &amp;quot;pools.tcl&amp;quot;, which will handle many pre-4.5 configurations.&lt;br /&gt;
** There are known issues when using this feature in conjunction with virtual servers; see the SourceForge bug list (and development mailing list archive) for details.&lt;br /&gt;
&lt;br /&gt;
=== I/O Features: ===&lt;br /&gt;
&lt;br /&gt;
* New '''Ns_QueueWait''' API to enable event-driven callbacks in the driver thread before dispatching to pools for processing.&lt;br /&gt;
&lt;br /&gt;
:The allows drivers to augment data received from the client (headers, request, content) with additional data fetched over the network (likely stored in the new Ns_Cls &amp;quot;connection local storage&amp;quot; API's) before dispatching to the connection threads.  An example would be to add certain personalization data received via a web service. The rationale here is that I/O events are cheap so do those upfront instead of having expensive connection threads burdened with wasteful blocking I/O.  This is a somewhat obscure and technical interface.&lt;br /&gt;
&lt;br /&gt;
* Added ability to manage larger file uploads by spooling to a temporary file (currenty not for Windows).&lt;br /&gt;
&lt;br /&gt;
* New '''[[nsproxy]]''' module which provides the '''ns_proxy command''' which enables sending Tcl scripts to a proxy process connected via a pipe. The proxy includes core Tcl commands as well as AOLserver commands from the libnsd library. Evaluating scripts in a proxy process can be used to isolate and/or timeout thread-unsafe or otherwise unsafe 3rd party code.&lt;br /&gt;
&lt;br /&gt;
=== ADP Improvements: ===&lt;br /&gt;
&lt;br /&gt;
* Added a new execution caching technique at the '''[[ns_adp_include]]''' level which allows you to save the results of execution of an included ADP and includes below that for reuse on subsequent connections up to a specified time.&lt;br /&gt;
* Added '''singlescript''' config option which turns ADP pages into a single script enabling syntax such as &amp;quot;&amp;lt;% foreach e $list { %&amp;gt; element &amp;lt;%= $e %&amp;gt; here &amp;lt;% } %&amp;gt;&amp;quot;.&lt;br /&gt;
* Added support for nested adp tags, i.e. you can now do  &amp;lt;% ns_adp_puts [ns_adp_eval {&amp;lt;% ... %&amp;gt;}] %&amp;gt; or use &amp;lt;% %&amp;gt; script within the body of a fancy tag.  Note that there is a known issue in that only a single inner instance of an adp tag is supported - see [http://sourceforge.net/tracker/?func=detail&amp;amp;aid=2958550&amp;amp;group_id=3152&amp;amp;atid=103152 Bug #2958550].&lt;br /&gt;
* Introduced a better command name to clear long-standing confusion between the previous registertag commands: '''[[ns_adp_registerscript]]''' instead of ns_register_adptag.&lt;br /&gt;
* Added '''[[ns_adp_registerproc]]''' which is similar to ns_adp_registerscript but the procedure receives individual arguments instead of an ns_set.&lt;br /&gt;
* Added output buffer improvements via new Ns_ConnFlush.  See '''[[ns_adp_close]]''' and '''[[ns_adp_flush]]'''&lt;br /&gt;
* Added automatic UTF-8 to output charset encoding.&lt;br /&gt;
* Added gzip output compression.&lt;br /&gt;
* Added streaming output in chunked-encoding format instead of the previous &amp;quot;response with no length&amp;quot; HTTP/1.0 method.&lt;br /&gt;
* Enhanced ADP error handling and reporting.&lt;br /&gt;
* Added ability to trace ADP pages.  Trace output is written to the server log.  See '''[[ns_adp_ctl]]''', which is a new command for configuring the ADP execution environment at runtime.&lt;br /&gt;
&lt;br /&gt;
=== Other Improvements: ===&lt;br /&gt;
&lt;br /&gt;
* New '''Ns_TclRegisterTrace''' API to enable callbacks at key state transition points in a much more natural way.  The [[ns_ictl]] command, which now has a second and better name that should be used going forward - '''[[ns_interp_ctl]]''', has been updated to support script-level traces.&lt;br /&gt;
* New '''Ns_Task''' API designed to replace the old Ns_SockCallback API which didn't do a very good job at managing timeouts along with I/O events.&lt;br /&gt;
* New '''[[ns_returnmoved]]''' command to return 301 http status code and redirect to a new URL.&lt;br /&gt;
* New '''[[ns_internalredirect]]''' command to restart connection processing with a new URL.&lt;br /&gt;
* 4.5.1 - Added '''ns_conn channel''' and '''ns_conn contentsentlength''' subcommands to [[ns_conn]] to allow raw communication via Tcl I/O to the remote client.&lt;br /&gt;
* New '''[[ns_cache]]''' command based on ideas from the [[nscache]] module.   This is semi-backward-compatible with the ns_cache module (differences are described in detail in [[ns_cache]]).&lt;br /&gt;
* New '''[[ns_loop_ctl]]''' command to monitor and manage ''for'', ''while'', and ''foreach'' loops.&lt;br /&gt;
* Added '''ns_ictl once''' subcommand to [[ns_ictl]] / [[ns_interp_ctl]] command to execute a script exactly once for a virtual server (i.e. at startup).&lt;br /&gt;
* Added '''ns_ictl package''' subcommand to [[ns_ictl]] / [[ns_interp_ctl]] command to handle loading of Tcl packages.&lt;br /&gt;
* Added '''ns_ictl cancel''' subcommand  to [[ns_ictl]] / [[ns_interp_ctl]] command to provide the ability to sendr async-cancel messages to any interpter listed in '''ns_ictl threads''' (another new subcommand)&lt;br /&gt;
* New '''[[ns_register_fastpath]]''' command to re-enable fastpath after a previous call to '''ns_register_proc'''.&lt;br /&gt;
* New '''[[ns_register_encoding]]''' command to enable mapping of method/URL combinations to specific charset encodings used to decode the request.&lt;br /&gt;
* 4.5.1 - New '''[[ns_register_cgi]]''' command to dynamically register a CGI executable to a url.&lt;br /&gt;
* New '''[[ns_driver]]''' command to get some stats on socket drivers.&lt;br /&gt;
* [[nszlib]] module is now integrated into the core and provides for on-the-fly gzip compression and other gzip facilities in [[ns_gzip]]&lt;br /&gt;
* -all switch added to '''[[ns_addrbyhost]]''' command.&lt;br /&gt;
* Added ability to access more AOLserver functionality from a tclsh (nsv_*, ns_thread, etc).&lt;br /&gt;
* Stack checking has returned.  In a multi-threaded application like AOLserver, stack checking is important for detecting buffer overruns and deep call trees blowing your thread stack, etc.&lt;br /&gt;
* More detailed information when logging uncaught Tcl errors.  Especially for connection threads, details of the HTTP request are logged to make diagnosing the root cause of errors easier.&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=What%27s_new_in_4.5&amp;diff=5817</id>
		<title>What's new in 4.5</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=What%27s_new_in_4.5&amp;diff=5817"/>
		<updated>2010-06-19T01:25:33Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a fairly comprehensive list of new features and changes in AOLserver 4.5 and 4.5.1 (compared to 4.0).  If you know of anything that is missing, please add it.&lt;br /&gt;
&lt;br /&gt;
=== Connection Management: ===&lt;br /&gt;
&lt;br /&gt;
These two commands can be used together to map slow running requests to a specific pool and to set limits to avoid overload.&lt;br /&gt;
&lt;br /&gt;
* New '''ns_pools''' command to map method/URL's to specific thread pools.&lt;br /&gt;
* New '''ns_limits''' command  control the number of threads executing and/or waiting for execution by method/URL.&lt;br /&gt;
*'''Note:''' The new scheme does not pick up connection thread pool configurations from earlier versions of AOLServer. Please see the new example configuration files, and the documentation for [[ns_pools]] and [[ns_limits]], for instructions in upgrading your configuration.  &lt;br /&gt;
** As of 1 August 2007, the HEAD revision contains &amp;quot;pools.tcl&amp;quot;, which will handle many pre-4.5 configurations.&lt;br /&gt;
** There are known issues when using this feature in conjunction with virtual servers; see the SourceForge bug list (and development mailing list archive) for details.&lt;br /&gt;
&lt;br /&gt;
=== I/O Features: ===&lt;br /&gt;
&lt;br /&gt;
* New '''Ns_QueueWait''' API to enable event-driven callbacks in the driver thread before dispatching to pools for processing.&lt;br /&gt;
&lt;br /&gt;
:The allows drivers to augment data received from the client (headers, request, content) with additional data fetched over the network (likely stored in the new Ns_Cls &amp;quot;connection local storage&amp;quot; API's) before dispatching to the connection threads.  An example would be to add certain personalization data received via a web service. The rationale here is that I/O events are cheap so do those upfront instead of having expensive connection threads burdened with wasteful blocking I/O.  This is a somewhat obscure and technical interface.&lt;br /&gt;
&lt;br /&gt;
* Added ability to manage larger file uploads by spooling to a temporary file (currenty not for Windows).&lt;br /&gt;
&lt;br /&gt;
* New '''[[nsproxy]]''' module which provides the ns_proxy command which enables sending Tcl scripts to a proxy process connected via a pipe. The proxy includes core Tcl commands as well as AOLserver commands from the libnsd library. Evaluating scripts in a proxy process can be used to isolate and/or timeout thread-unsafe or otherwise unsafe 3rd party code.&lt;br /&gt;
&lt;br /&gt;
=== ADP Improvements: ===&lt;br /&gt;
&lt;br /&gt;
* Added a new execution caching technique at the '''[[ns_adp_include]]''' level which allows you to save the results of execution of an included ADP and includes below that for reuse on subsequent connections up to a specified time.&lt;br /&gt;
* Added '''singlescript''' config option which turns ADP pages into a single script enabling syntax such as &amp;quot;&amp;lt;% foreach e $list { %&amp;gt; element &amp;lt;%= $e %&amp;gt; here &amp;lt;% } %&amp;gt;&amp;quot;.&lt;br /&gt;
* Added support for nested adp tags, i.e. you can now do  &amp;lt;% ns_adp_puts [ns_adp_eval {&amp;lt;% ... %&amp;gt;}] %&amp;gt; or use &amp;lt;% %&amp;gt; script within the body of a fancy tag.  Note that there is a known issue in that only a single inner instance of an adp tag is supported - see [http://sourceforge.net/tracker/?func=detail&amp;amp;aid=2958550&amp;amp;group_id=3152&amp;amp;atid=103152 Bug #2958550].&lt;br /&gt;
* Introduced a better command name to clear long-standing confusion between the previous registertag commands: '''[[ns_adp_registerscript]]''' instead of ns_register_adptag.&lt;br /&gt;
* Added '''[[ns_adp_registerproc]]''' which is similar to ns_adp_registerscript but the procedure receives individual arguments instead of an ns_set.&lt;br /&gt;
* Added output buffer improvements via new Ns_ConnFlush.  See '''[[ns_adp_close]]''' and '''[[ns_adp_flush]]'''&lt;br /&gt;
* Added automatic UTF-8 to output charset encoding.&lt;br /&gt;
* Added gzip output compression.&lt;br /&gt;
* Added streaming output in chunked-encoding format instead of the previous &amp;quot;response with no length&amp;quot; HTTP/1.0 method.&lt;br /&gt;
* Enhanced ADP error handling and reporting.&lt;br /&gt;
* Added ability to trace ADP pages.  Trace output is written to the server log.  See '''[[ns_adp_ctl]]''', which is a new command for configuring the ADP execution environment at runtime.&lt;br /&gt;
&lt;br /&gt;
=== Other Improvements: ===&lt;br /&gt;
&lt;br /&gt;
* New '''Ns_TclRegisterTrace''' API to enable callbacks at key state transition points in a much more natural way.  The [[ns_ictl]] command, which now has a second and better name that should be used going forward - '''[[ns_interp_ctl]]''', has been updated to support script-level traces.&lt;br /&gt;
* New '''Ns_Task''' API designed to replace the old Ns_SockCallback API which didn't do a very good job at managing timeouts along with I/O events.&lt;br /&gt;
* New '''[[ns_returnmoved]]''' command to return 301 http status code and redirect to a new URL.&lt;br /&gt;
* New '''[[ns_internalredirect]]''' command to restart connection processing with a new URL.&lt;br /&gt;
* 4.5.1 - Added '''ns_conn channel''' and '''ns_conn contentsentlength''' subcommands to [[ns_conn]] to allow raw communication via Tcl I/O to the remote client.&lt;br /&gt;
* New '''[[ns_cache]]''' command based on ideas from the [[nscache]] module.   This is semi-backward-compatible with the ns_cache module (differences are described in detail in [[ns_cache]]).&lt;br /&gt;
* New '''[[ns_loop_ctl]]''' command to monitor and manage ''for'', ''while'', and ''foreach'' loops.&lt;br /&gt;
* Added '''ns_ictl once''' subcommand to [[ns_ictl]] / [[ns_interp_ctl]] command to execute a script exactly once for a virtual server (i.e. at startup).&lt;br /&gt;
* Added '''ns_ictl package''' subcommand to [[ns_ictl]] / [[ns_interp_ctl]] command to handle loading of Tcl packages.&lt;br /&gt;
* Added '''ns_ictl cancel''' subcommand  to [[ns_ictl]] / [[ns_interp_ctl]] command to provide the ability to sendr async-cancel messages to any interpter listed in '''ns_ictl threads''' (another new subcommand)&lt;br /&gt;
* New '''[[ns_register_fastpath]]''' command to re-enable fastpath after a previous call to '''ns_register_proc'''.&lt;br /&gt;
* New '''[[ns_register_encoding]]''' command to enable mapping of method/URL combinations to specific charset encodings used to decode the request.&lt;br /&gt;
* 4.5.1 - New '''[[ns_register_cgi]]''' command to dynamically register a CGI executable to a url.&lt;br /&gt;
* New '''[[ns_driver]]''' command to get some stats on socket drivers.&lt;br /&gt;
* [[nszlib]] module is now integrated into the core and provides for on-the-fly gzip compression and other gzip facilities in [[ns_gzip]]&lt;br /&gt;
* -all switch added to '''[[ns_addrbyhost]]''' command.&lt;br /&gt;
* Added ability to access more AOLserver functionality from a tclsh (nsv_*, ns_thread, etc).&lt;br /&gt;
* Stack checking has returned.  In a multi-threaded application like AOLserver, stack checking is important for detecting buffer overruns and deep call trees blowing your thread stack, etc.&lt;br /&gt;
* More detailed information when logging uncaught Tcl errors.  Especially for connection threads, details of the HTTP request are logged to make diagnosing the root cause of errors easier.&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=What%27s_new_in_4.5&amp;diff=5816</id>
		<title>What's new in 4.5</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=What%27s_new_in_4.5&amp;diff=5816"/>
		<updated>2010-06-19T01:20:11Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a fairly comprehensive list of new features and changes in AOLserver 4.5 and 4.5.1 (compared to 4.0).  If you know of anything that is missing, please add it.&lt;br /&gt;
&lt;br /&gt;
=== Connection Management: ===&lt;br /&gt;
&lt;br /&gt;
These two commands can be used together to map slow running requests to a specific pool and to set limits to avoid overload.&lt;br /&gt;
&lt;br /&gt;
* New '''ns_pools''' command to map method/URL's to specific thread pools.&lt;br /&gt;
* New '''ns_limits''' command  control the number of threads executing and/or waiting for execution by method/URL.&lt;br /&gt;
*'''Note:''' The new scheme does not pick up connection thread pool configurations from earlier versions of AOLServer. Please see the new example configuration files, and the documentation for [[ns_pools]] and [[ns_limits]], for instructions in upgrading your configuration.  &lt;br /&gt;
** As of 1 August 2007, the HEAD revision contains &amp;quot;pools.tcl&amp;quot;, which will handle many pre-4.5 configurations.&lt;br /&gt;
** There are known issues when using this feature in conjunction with virtual servers; see the SourceForge bug list (and development mailing list archive) for details.&lt;br /&gt;
&lt;br /&gt;
=== I/O Features: ===&lt;br /&gt;
&lt;br /&gt;
* New '''Ns_QueueWait''' API to enable event-driven callbacks in the driver thread before dispatching to pools for processing.&lt;br /&gt;
&lt;br /&gt;
:The allows drivers to augment data received from the client (headers, request, content) with additional data fetched over the network (likely stored in the new Ns_Cls &amp;quot;connection local storage&amp;quot; API's) before dispatching to the connection threads.  An example would be to add certain personalization data received via a web service. The rationale here is that I/O events are cheap so do those upfront instead of having expensive connection threads burdened with wasteful blocking I/O.  This is a somewhat obscure and technical interface.&lt;br /&gt;
&lt;br /&gt;
* Added ability to manage larger file uploads by spooling to a temporary file (currenty not for Windows).&lt;br /&gt;
&lt;br /&gt;
* New [[nsproxy]] module which provides the ns_proxy command which enables sending Tcl scripts to a proxy process connected via a pipe. The proxy includes core Tcl commands as well as AOLserver commands from the libnsd library. Evaluating scripts in a proxy process can be used to isolate and/or timeout thread-unsafe or otherwise unsafe 3rd party code.&lt;br /&gt;
&lt;br /&gt;
=== ADP Improvements: ===&lt;br /&gt;
&lt;br /&gt;
* Added a new execution caching technique at the '''[[ns_adp_include]]''' level which allows you to save the results of execution of an included ADP and includes below that for reuse on subsequent connections up to a specified time.&lt;br /&gt;
* Added '''singlescript''' config option which turns ADP pages into a single script enabling syntax such as &amp;quot;&amp;lt;% foreach e $list { %&amp;gt; element &amp;lt;%= $e %&amp;gt; here &amp;lt;% } %&amp;gt;&amp;quot;.&lt;br /&gt;
* Added support for nested adp tags, i.e. you can now do  &amp;lt;% ns_adp_puts [ns_adp_eval {&amp;lt;% ... %&amp;gt;}] %&amp;gt; or use &amp;lt;% %&amp;gt; script within the body of a fancy tag.  Note that there is a known issue in that only a single inner instance of an adp tag is supported - see [http://sourceforge.net/tracker/?func=detail&amp;amp;aid=2958550&amp;amp;group_id=3152&amp;amp;atid=103152 Bug #2958550].&lt;br /&gt;
* Introduced a better command name to clear long-standing confusion between the previous registertag commands: '''[[ns_adp_registerscript]]''' instead of ns_register_adptag.&lt;br /&gt;
* Added '''[[ns_adp_registerproc]]''' which is similar to ns_adp_registerscript but the procedure receives individual arguments instead of an ns_set.&lt;br /&gt;
* Added output buffer improvements via new Ns_ConnFlush.  See '''[[ns_adp_close]]''' and '''[[ns_adp_flush]]'''&lt;br /&gt;
* Added automatic UTF-8 to output charset encoding.&lt;br /&gt;
* Added gzip output compression.&lt;br /&gt;
* Added streaming output in chunked-encoding format instead of the previous &amp;quot;response with no length&amp;quot; HTTP/1.0 method.&lt;br /&gt;
* Enhanced ADP error handling and reporting.&lt;br /&gt;
* Added ability to trace ADP pages.  Trace output is written to the server log.  See '''[[ns_adp_ctl]]''', which is a new command for configuring the ADP execution environment at runtime.&lt;br /&gt;
&lt;br /&gt;
=== Other Improvements: ===&lt;br /&gt;
&lt;br /&gt;
* New '''Ns_TclRegisterTrace''' API to enable callbacks at key state transition points in a much more natural way.  The [[ns_ictl]] command, which now has a second and better name that should be used going forward - '''[[ns_interp_ctl]]''', has been updated to support script-level traces.&lt;br /&gt;
* New '''Ns_Task''' API designed to replace the old Ns_SockCallback API which didn't do a very good job at managing timeouts along with I/O events.&lt;br /&gt;
* New '''[[ns_returnmoved]]''' command to return 301 http status code and redirect to a new URL.&lt;br /&gt;
* New '''[[ns_internalredirect]]''' command to restart connection processing with a new URL.&lt;br /&gt;
* 4.5.1 - Added '''ns_conn channel''' and '''ns_conn contentsentlength''' subcommands to [[ns_conn]] to allow raw communication via Tcl I/O to the remote client.&lt;br /&gt;
* New '''[[ns_cache]]''' command based on ideas from the [[nscache]] module.   This is semi-backward-compatible with the ns_cache module (differences are described in detail in [[ns_cache]]).&lt;br /&gt;
* New '''[[ns_loop_ctl]]''' command to monitor and manage ''for'', ''while'', and ''foreach'' loops.&lt;br /&gt;
* Added '''ns_ictl once''' subcommand to [[ns_ictl]] / [[ns_interp_ctl]] command to execute a script exactly once for a virtual server (i.e. at startup).&lt;br /&gt;
* Added '''ns_ictl package''' subcommand to [[ns_ictl]] / [[ns_interp_ctl]] command to handle loading of Tcl packages.&lt;br /&gt;
* Added '''ns_ictl cancel''' subcommand  to [[ns_ictl]] / [[ns_interp_ctl]] command to provide the ability to sendr async-cancel messages to any interpter listed in '''ns_ictl threads''' (another new subcommand)&lt;br /&gt;
* New '''[[ns_register_fastpath]]''' command to re-enable fastpath after a previous call to '''ns_register_proc'''.&lt;br /&gt;
* New '''[[ns_register_encoding]]''' command to enable mapping of method/URL combinations to specific charset encodings used to decode the request.&lt;br /&gt;
* 4.5.1 - New '''[[ns_register_cgi]]''' command to dynamically register a CGI executable to a url.&lt;br /&gt;
* New '''[[ns_driver]]''' command to get some stats on socket drivers.&lt;br /&gt;
* [[nszlib]] module is now integrated into the core and provides for on-the-fly gzip compression and other gzip facilities in [[ns_gzip]]&lt;br /&gt;
* -all switch added to '''[[ns_addrbyhost]]''' command.&lt;br /&gt;
* Added ability to access more AOLserver functionality from a tclsh (nsv_*, ns_thread, etc).&lt;br /&gt;
* Stack checking has returned.  In a multi-threaded application like AOLserver, stack checking is important for detecting buffer overruns and deep call trees blowing your thread stack, etc.&lt;br /&gt;
* More detailed information when logging uncaught Tcl errors.  Especially for connection threads, details of the HTTP request are logged to make diagnosing the root cause of errors easier.&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Nszlib&amp;diff=5815</id>
		<title>Nszlib</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Nszlib&amp;diff=5815"/>
		<updated>2010-06-19T00:59:55Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Author: [[Vlad Seryakov]]&lt;br /&gt;
&lt;br /&gt;
This is AOLserver module that implements Zlib interface.&lt;br /&gt;
Allows compressing/uncompressing Tcl strings as well as gzip file support.&lt;br /&gt;
&lt;br /&gt;
Integrated into the AOLserver core as of version 4.5 - see [[ns_zlib]]&lt;br /&gt;
&lt;br /&gt;
Download: http://www.crystalballinc.com/vlad/software/ for older versions of AOLserver&lt;br /&gt;
&lt;br /&gt;
'''EXAMPLES'''&lt;br /&gt;
&lt;br /&gt;
    # Compress Tcl string&lt;br /&gt;
    set test &amp;quot;This is test string for compression&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    set data [ns_zlib compress $test]&lt;br /&gt;
&lt;br /&gt;
    set test [ns_zlib uncompress $data]&lt;br /&gt;
    ns_log Debug Uncompress: $test&lt;br /&gt;
&lt;br /&gt;
    # Compress the string into gzip format&lt;br /&gt;
    set gzip [ns_zlib gzip $test]&lt;br /&gt;
&lt;br /&gt;
    # Save as gzip file&lt;br /&gt;
    set fd [open /tmp/test.gz w]&lt;br /&gt;
    fconfigure $fd -translation binary -encoding binary&lt;br /&gt;
    puts -nonewline $fd $gzip&lt;br /&gt;
    close $fd&lt;br /&gt;
&lt;br /&gt;
    # Uncompress gzipped file&lt;br /&gt;
    set test [ns_zlib gunzip /tmp/test.gz]&lt;br /&gt;
    ns_log Debug Ungzipped: $test&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_adp_ctl&amp;diff=5814</id>
		<title>Ns adp ctl</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_adp_ctl&amp;diff=5814"/>
		<updated>2010-06-19T00:47:47Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;manpage&amp;gt;ns_adp_ctl&amp;lt;/manpage&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''NAME'''&lt;br /&gt;
&lt;br /&gt;
: ns_adp_ctl - Control current ADP execution environment (new in AOLserver 4.5)&lt;br /&gt;
&lt;br /&gt;
'''SYNOPSIS'''&lt;br /&gt;
&lt;br /&gt;
: '''ns_adp_ctl''' ''option ?bool | arg?''&lt;br /&gt;
&lt;br /&gt;
'''DESCRIPTION'''&lt;br /&gt;
&lt;br /&gt;
: This command enables control of the current ADP execution environment.  '''See Notes for an important known issue'''&lt;br /&gt;
&lt;br /&gt;
: Aside from the ''bufsize'' and ''chan'' subcommands, they all return a boolean value for a given ADP option.  If the ''bool'' argument is given, the option is set to the given value and the ''previous'' value is returned.&lt;br /&gt;
&lt;br /&gt;
: Most of the options have equivalent config file settings which provide the server defaults in the ns/server/servername/adp section.&lt;br /&gt;
&lt;br /&gt;
: The legal ''option''s (which may be abbreviated) are:&lt;br /&gt;
&lt;br /&gt;
* '''ns_adp_ctl bufsize''' ''?size?''&lt;br /&gt;
:  This command returns the current ADP output buffer size, setting it to a new value if the optionial ''size'' argument is specified.  ''bufsize'' config setting defaults to 1000 KB.&lt;br /&gt;
&lt;br /&gt;
* '''ns_adp_ctl chan''' ''channel''&lt;br /&gt;
: This command is used to specify an open file channel to receive output when the buffer is flushed. If ''channel'' is the null string, the output channel is cleared.  This capability can be useful for specialized uses of ADP outside the context of an HTTP connection, e.g., for debugging or testing.&lt;br /&gt;
&lt;br /&gt;
* '''ns_adp_ctl autoabort''' ''?bool?''&lt;br /&gt;
: Query or set the ''autoabort'' option.  When enabled, failure to flush a buffer (normally the result of a closed HTTP connection) generates an ADP exception, unwinding the ADP call stack.  ''autoabort'' config setting defaults to ''true''.&lt;br /&gt;
&lt;br /&gt;
* '''ns_adp_ctl detailerror''' ''?bool?''&lt;br /&gt;
: Query or set the ''detailerror'' option.  When enabled, errors in ADP pages are formatted with information about the context of the HTTP request.  This can be very helpful in debugging ADP errors but potentially a security risk if the HTTP context (e.g., cookie headers) contains personal or sensitive data.  Errors are logged to the server log and, if ''displayerror'' is enabled, appened to the output buffer.  ''detailerror'' config setting defaults to ''true''.&lt;br /&gt;
&lt;br /&gt;
* '''ns_adp_ctl displayerror''' ''?bool?''&lt;br /&gt;
: Query or set the ''displayerror'' option.  When enabled, errors in ADP pages are formatted and appended to the output stream, normally visiable to a user's browser.  This option should generally be enabled in development and disabled in production.  ''displayerror'' config setting defaults to ''false''.&lt;br /&gt;
&lt;br /&gt;
* '''ns_adp_ctl expire''' ''?bool?''&lt;br /&gt;
: Query or set the ''expire'' option.  When enabled, the ADP request processing code adds an &amp;quot;Expires: now&amp;quot; header in the response buffer to disable any caching.  In practice, more thoughtful cache control mechanisms should be used based on the HTTP/1.1 spec.  ''enableexpire'' config setting defaults to ''false''.&lt;br /&gt;
&lt;br /&gt;
* '''ns_adp_ctl gzip''' ''?bool?''&lt;br /&gt;
: Query or set the ''gzip'' option.  When enabled, the output buffer is compressed before being returned in the response.  As ADP's are generally used to generate text data such as HTML or XML, compression is normally quite successful at reducing the response size.  ''gzip'' config setting defaults to ''false''.&lt;br /&gt;
: In AOLserver 4.0, ns_adp_compress command (now deprecated) did the same thing but did not return anything.  Note that in AOLserver 4.5, this flag is separate from the [[ns_conn]] compress flag and while you can use this to ''enable'' compression for the current ADP request, you cannot use this to disable the ns_conn compress flag, which if set to enabled (by a filter for example) will override your attempt to disable using this command.&lt;br /&gt;
&lt;br /&gt;
* '''ns_adp_ctl ignorefinalflusherrors''' ''?bool?''&lt;br /&gt;
: New in 4.5.2: Query or set the ''IgnoreFinalFlushErrors'' option.  Flushing ADP output buffer at the end of processing an adp page might occur after the connection is already closed (i.e. browser has disconnected). In addition, pre-AOLserver 4.5 code could omit a call to ns_adp_abort when doing an ns_returnredirect or the like without ill effects, whereas in AOLserver 4.5 this causes an error to be logged. It is therefore desirable to have the option to ignore these errors altogether which was the behavior prior to version 4.5.  When this setting is on, flush errors that occur at the end of the request are silently ignored without causing an error to be logged.  Flush errors that occur in the middle of a request such as when streaming or using [[ns_adp_flush]] or when the ADP buffer overflows will continue to throw errors. ''IgnoreFinalFlushErrors'' config setting defaults to ''false''.&lt;br /&gt;
&lt;br /&gt;
* '''ns_adp_ctl nocache''' ''?bool?''&lt;br /&gt;
: Query or set the ''nocache'' option.  When enabled, all requests to cache executed ADP blocks via the [[ns_adp_include]] -cache'' directive are ignored, resulting in normal execution of all code.&lt;br /&gt;
&lt;br /&gt;
* '''ns_adp_ctl safe''' ''?bool?''&lt;br /&gt;
: Query or set the ''safe'' option. When enabled, all code is executed in &amp;quot;safe&amp;quot; mode, disabling and ignoring any code within &amp;lt;% ... %&amp;gt; tags and only allowing execution of previously defined registered tags.  ''safeeval'' config setting defaults to ''false''.&lt;br /&gt;
&lt;br /&gt;
* '''ns_adp_ctl singlescript''' ''?bool?''&lt;br /&gt;
: Query or set the ''singlescript'' option.  When enabled, ADP pages are converted from independent text-script blocks into a single script, with text blocks replaced with a call to [[ns_adp_append]] with the given text.  ''singlescript'' config setting defaults to ''false''.&lt;br /&gt;
: The purpose of this option is to enable tcl code that spans blocks, similar to old-style Microsoft ASP.  While this can sometimes be convenient, it is not a recommended practice. Also, one side-effect of this is that an error anywhere on the page will result in the entire ADP page returning instead of skipping to the next block which is the normal behavior, just like with ''stricterror'' on. Example adp script that only works with ''singlescript'' on:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;%&lt;br /&gt;
      while {[ns_db getrow $db $row]} {&lt;br /&gt;
    %&amp;gt;&lt;br /&gt;
        Blah &amp;lt;%=[ns_set get $row blah]%&amp;gt;&lt;br /&gt;
        ...more html code goes here...&lt;br /&gt;
    &amp;lt;%&lt;br /&gt;
      }&lt;br /&gt;
    %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''ns_adp_ctl stricterror''' ''?bool?''&lt;br /&gt;
: Query or set the ''stricterror'' option.  When enabled, the result is similar to that of ''singlescript'' in that an error in a particular block will abort execution and return the current buffer instead of continuing to the next text or script block.  ''stricterror'' config setting defaults to ''false''.&lt;br /&gt;
&lt;br /&gt;
* '''ns_adp_ctl trace''' ''?bool?''&lt;br /&gt;
: Query or set the ''trace'' option.  When enabled, the first X characters of each ''compiled'' adp block are logged to the server log. X defaults to 40 characters and can be configured only in the config file using the ''tracesize'' setting.&lt;br /&gt;
&lt;br /&gt;
* '''ns_adp_ctl trimspace''' ''?bool?''&lt;br /&gt;
: Query or set the ''trimspace'' option.  When enabled, any white space at the start of the output buffer is eliminated.  White space can show up in the output as a result of ADP pages which do nothing but include other ADP's in a way to reuse code with the unfortunate side effect of the training newline at the end of a &amp;quot;&amp;lt;% ns_adp_include myfile.adp %&amp;gt;&amp;quot; ending up in the output stream.  ''trimspace'' config setting defaults to ''false''.&lt;br /&gt;
&lt;br /&gt;
'''NOTES'''&lt;br /&gt;
&lt;br /&gt;
: '''IMPORTANT:''' While this command is typically used in requests for adp pages, you can also use it in requests for registered procedures, scheduled procs, etc. that ns_adp_parse adp scripts or pages. One common setting you might set in such context is ''displayerror'' or ''safe''.  Currently, when ns_adp_ctl is used to set settings outside of an adp request, the configuration changes are NOT cleared at the end of the request and are persisted between connections for the given thread!&lt;br /&gt;
&lt;br /&gt;
'''SEE ALSO'''&lt;br /&gt;
&lt;br /&gt;
: [[ns_adp_abort]], [[ns_adp_append]], [[ns_adp_argc]], [[ns_adp_argv]], [[ns_adp_bind_args]], [[ns_adp_break]], [[ns_adp_close]], [[ns_adp_debug]], [[ns_adp_debuginit]], [[ns_adp_dir]], [[ns_adp_dump]], [[ns_adp_eval]], [[ns_adp_exception]], [[ns_adp_include]], [[ns_adp_mime]], [[ns_adp_mimetype]], [[ns_adp_parse]], [[ns_adp_puts]], [[ns_adp_registeradp]], [[ns_adp_registerproc]], [[ns_adp_registertag]], [[ns_adp_return]], [[ns_adp_safeeval]], [[ns_adp_stats]], [[ns_adp_stream]], [[ns_adp_tell]]&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
[[Category:Core Tcl API]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_internalredirect&amp;diff=5813</id>
		<title>Ns internalredirect</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_internalredirect&amp;diff=5813"/>
		<updated>2010-06-19T00:32:31Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: Created page with ''''NAME'''  : ns_internaledirect - Re-authorize and restart url processing (new in AOLserver 4.5)  '''SYNOPSIS'''  : '''ns_internaledirect''' ''?connid? url''  '''DESCRIPTION''' …'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''NAME'''&lt;br /&gt;
&lt;br /&gt;
: ns_internaledirect - Re-authorize and restart url processing (new in AOLserver 4.5)&lt;br /&gt;
&lt;br /&gt;
'''SYNOPSIS'''&lt;br /&gt;
&lt;br /&gt;
: '''ns_internaledirect''' ''?connid? url''&lt;br /&gt;
&lt;br /&gt;
'''DESCRIPTION'''&lt;br /&gt;
&lt;br /&gt;
: The '''ns_internalredirect''' command enables re-authorization and restart of a connection as if it were originally for a different URL. It is possible now to set new request url and re-process the request from the beginning without using external redirect. Internal redirect assigns new url and calls registered proc for new url inside the existing connection and using the same Tcl interpreter with all the same global variables, database handles, etc. still available.&lt;br /&gt;
: The optional ''connid'' parameter is deprecated and should not be used.&lt;br /&gt;
: The url should NOT have the http://host location, just the url portion starting with a /.&lt;br /&gt;
&lt;br /&gt;
'''NOTES'''&lt;br /&gt;
&lt;br /&gt;
: The script does not end at the time this command is invoked.  When used in an adp page, [[ns_adp_abort]] or [[ns_adp_return]] should be called to end script processing after '''ns_internalredirect'''.&lt;br /&gt;
&lt;br /&gt;
: While nsperms request authorization always happens on the new url, neither preauth, nor postauth filters are executed.  In the future, this command may be enhanced with the option to bypass authorization.&lt;br /&gt;
&lt;br /&gt;
: After executing the target url (whether it's an adp page or a registered procedure), control returns to the caller of this command but [[ns_conn]] url will continue to report the url passed to '''ns_internalredirect'''.  Trace filters will also fire for this new url and so the access log will reflect the new url, not the originally requested one.&lt;br /&gt;
&lt;br /&gt;
: One thing to keep in mind about '''ns_internalredirect''' is the browser retains the url to which it posted, which is sometimes undesireable because you don't want it bookmarked or you don't want a refresh to resubmit the POST.  In such scenarios an actual [[ns_returnredirect]] is more appropriate.&lt;br /&gt;
&lt;br /&gt;
'''EXAMPLES'''&lt;br /&gt;
&lt;br /&gt;
    ns_internalredirect /errorpage.adp&lt;br /&gt;
&lt;br /&gt;
'''SEE ALSO'''&lt;br /&gt;
&lt;br /&gt;
: [[ns_return]], [[ns_returnadminnotice]], [[ns_returnbadrequest]], [[ns_returnerror]], [[ns_returnfile]], [[ns_returnforbidden]], [[ns_returnfp]], [[ns_returnnotfound]], [[ns_returnnotice]], [[ns_returnok]], [[ns_returnunauthorized]], [[ns_returnmoved]], [[ns_internalredirect]]&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]] - [[Category:Core Tcl API]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_returnredirect&amp;diff=5812</id>
		<title>Ns returnredirect</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_returnredirect&amp;diff=5812"/>
		<updated>2010-06-18T22:59:46Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Man page: http://aolserver.com/docs/tcl/ns_returnredirect.html&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''NAME'''&lt;br /&gt;
&lt;br /&gt;
: ns_returnredirect - Redirect the client to another location&lt;br /&gt;
&lt;br /&gt;
'''SYNOPSIS'''&lt;br /&gt;
&lt;br /&gt;
: '''ns_returnredirect''' ''?connid? url''&lt;br /&gt;
&lt;br /&gt;
'''DESCRIPTION'''&lt;br /&gt;
&lt;br /&gt;
: This command redirects the client by returning a 302 (Redirection) HTTP status code, and a Location header pointing at ''url''.&lt;br /&gt;
&lt;br /&gt;
: The optional ''connid'' parameter is deprecated and should not be used.&lt;br /&gt;
&lt;br /&gt;
: '''NOTE:''' The script does not end at the time this command is invoked.  When used in an adp page, [[ns_adp_abort]] or [[ns_adp_return]] should be called to end script processing after '''ns_returnredirect'''.&lt;br /&gt;
&lt;br /&gt;
: AOLserver 4.5 also includes an [[ns_returnmoved]] command (tcl procedure actually) which implements a redirect using the 301 code.&lt;br /&gt;
&lt;br /&gt;
'''EXAMPLES'''&lt;br /&gt;
&lt;br /&gt;
    ns_returnredirect http://www.aolserver.com/&lt;br /&gt;
&lt;br /&gt;
'''SEE ALSO'''&lt;br /&gt;
&lt;br /&gt;
: [[ns_return]], [[ns_returnadminnotice]], [[ns_returnbadrequest]], [[ns_returnerror]], [[ns_returnfile]], [[ns_returnforbidden]], [[ns_returnfp]], [[ns_returnnotfound]], [[ns_returnnotice]], [[ns_returnok]], [[ns_returnunauthorized]], [[ns_returnmoved]], [[ns_internalredirect]]&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]] - [[Category:Core Tcl API]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_ictl&amp;diff=5811</id>
		<title>Ns ictl</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_ictl&amp;diff=5811"/>
		<updated>2010-06-18T22:42:29Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Man page: http://aolserver.com/docs/tcl/ns_ictl.html&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''NAME'''&lt;br /&gt;
&lt;br /&gt;
: ns_ictl - Manipulate and introspect Tcl interpreter internals&lt;br /&gt;
&lt;br /&gt;
'''SYNOPSIS'''&lt;br /&gt;
&lt;br /&gt;
: '''ns_ictl''' ''option ?arg arg ...?''&lt;br /&gt;
&lt;br /&gt;
'''DESCRIPTION'''&lt;br /&gt;
&lt;br /&gt;
: This command provides access to the internal facilities to control and configure multi-threaded Tcl interpreters in the context of AOLserver virtual servers.  It is normally used in startup initialization scripts to define how new interpreters are initialized when created and to support cleanup and re-initalization between transactions (e.g., HTTP connections).  &lt;br /&gt;
*'''ns_ictl addmodule''' ''module''&lt;br /&gt;
: Add a module to the list of modules to be initialized at startup and returns the new list as the result. This command is not normally required as each module specified in the AOLserver modules config section for the corresponding server (e.g., ''ns/server/server1/modules'') is automatically added to the list.  To be clear, this command simply appens the ''module'' to the list, it doesn't perform any loading of modules.&lt;br /&gt;
*'''ns_ictl cancel''' ''thread''&lt;br /&gt;
: Send an asynchronous interrupt request to the specified thread, cancelling any script currently executing on any AOLserver created interpreter (note the interrupt is not virtual-server specific). This command utilizes the facilities of '''Tcl_AsyncMark''' to mark as ready a callback registered with '''Tcl_AsyncCreate'''. The callback places an &amp;quot;async cancel&amp;quot; error message in the interpreter result and returns '''TCL_ERROR''' to unwind the call stack. The underlying Tcl facility has limitations, e.g., the interrupt will only be noticed when Tcl checks via '''Tcl_AsyncReady''' calls between commands and the interrupt can be caught with a '''catch''' command. See the man page for '''Tcl_AsyncCreate''' for details.  This command will throw an error if the thread doesn't have a tcl interpreter and will otherwise return nothing whether the interpreter is actively running or not.&lt;br /&gt;
*'''ns_ictl cleanup'''&lt;br /&gt;
: This command invokes any callbacks registered during a transaction via the C-level '''Ns_TclRegisterDefer''' routine.  Unlike callbacks registered with the '''ns_ictl trace deallocate''' command or '''Ns_TclRegisterTrace''' routine, these callbacks are executed only once and there is no Tcl-level access to the underlying '''Ns_TclRegisterDefer''' routine.  Currently the only thing that uses this is the C code that releases database handles.  This command is invoked by [[ns_cleanup]] Tcl procedure.&lt;br /&gt;
*'''ns_ictl epoch'''&lt;br /&gt;
: This command returns the unique id for the current duplication script for the virtual server.  The id starts as 0 when the virtual server is created and is incremented each time a new script is saved via the '''ns_ictl save''' command.  &lt;br /&gt;
*'''ns_ictl get'''&lt;br /&gt;
: Return the current duplication script for the virtual server.  This command is useful to view the duplication script created by the initialization script at startup.  &lt;br /&gt;
*'''ns_ictl getmodules'''&lt;br /&gt;
: Return the list of modules to be initialized at startup. This list corresponds to the names of modules specified in the virtual server modules config section, e.g., ''ns/server/server1/modules'' unless additional modules are added via the '''ns_ictl addmodule''' command.  &lt;br /&gt;
*'''ns_ictl gettraces''' ''which''&lt;br /&gt;
: Return the list of traces which will be invoked at the specified time. The ''which'' argument can be one of ''create, delete, allocate, deallocate, getconn'', or ''freeconn''.  The traces are returned in the order in which they will be executed.  Script level traces are returns as strings to evaluate and C-level traces are returned with strings which specify the address of the underlying C procedure and argument.  &lt;br /&gt;
*'''ns_ictl once''' ''key script''&lt;br /&gt;
: Evaluate given script once in the virtual server. The given key is a string name which uniquely identifies the corresponding script. This command is useful in a Tcl package which includes one-time initialization routines, e.g., calls to '''ns_register_proc''' or initialization of shared variables using '''nsv_set''' (see '''EXAMPLES''' below).  &lt;br /&gt;
*'''ns_ictl oncleanup''' ''script''&lt;br /&gt;
: This command is equivalent to '''ns_ictl trace deallocate''' ''script''.  &lt;br /&gt;
*'''ns_ictl oncreate''' ''script''&lt;br /&gt;
: This command is equivalent to '''ns_ictl trace create''' ''script''.  &lt;br /&gt;
*'''ns_ictl ondelete''' ''script''&lt;br /&gt;
: This command is equivalent to '''ns_ictl trace delete''' ''script''.  &lt;br /&gt;
*'''ns_ictl oninit''' ''script''&lt;br /&gt;
: This command is equivalent to '''ns_ictl trace allocate''' ''script''.  &lt;br /&gt;
*'''ns_ictl package''' ''?-exact? package ?version?''&lt;br /&gt;
: This command is used to require a package in the calling interpreter and, if successfully loaded, it will require the exact same version in all other interpreters for the virtual server. If version consistency is not important, you can achieve the same effect with '''ns_ictl trace allocate''' {package require ''package''}. In addition, allocate too frequent for most packages.  Package state is retained between thread allocations in a given interpreter, so at startup, doing ns_ictl oninit {package require ''package''} should be sufficient and will also work in AOLserver 4.0.  This option can be useful, however, if you want to alter the state of already created interpreters at runtime.&lt;br /&gt;
*'''ns_ictl runtraces''' which''&lt;br /&gt;
: This command runs the requested traces. The ''which'' argument must be one of '''create''', '''delete''', '''allocate''', '''deallocate''', '''getconn''', or '''freeconn'''.  Direct calls to this command are not normally necessary as the underlying C code will invoke the callbacks at the required times.  Exceptions include calling '''ns_ictl runtraces''' or testing purposes or to mimic the normal cleanup and initialization work performed on between transactions in a long running thread (see '''EXAMPLES''' below).  &lt;br /&gt;
*'''ns_ictl save''' ''script''&lt;br /&gt;
: Save the given script as the duplication script, incrementing the virtual server epoch number.  This command is normally called by the bootstrap script after constructing the script to duplicate the procedures defined by sourcing the various module initialization script files.  It's also used by [[ns_eval]] to dynamically update the interpreter 'template'.&lt;br /&gt;
*'''ns_ictl threads'''&lt;br /&gt;
: Return a list of all threads with interpreters in this processs. The ids return are small strings which represent the underlying thread ids and can be passed to the '''ns_ictl cancel''' command to send an asynchronous cancel request.  Note that the list will include currently idle threads as long as at some point they had allocated an interpreter.&lt;br /&gt;
*'''ns_ictl trace create''' ''script''&lt;br /&gt;
: Register ''script'' to be called when an interpreter is first created. This is useful to create procedures, require packages, or initialize other state to be used during the lifetime of the interpreter.  &lt;br /&gt;
*'''ns_ictl trace delete''' ''script''&lt;br /&gt;
: Register ''script'' to be called before an interpreter is destroyed. This is useful to free any resources which may have been allocated for the interpreter during the lifetime of the interpreter.  &lt;br /&gt;
*'''ns_ictl trace allocate''' ''script''&lt;br /&gt;
: Register ''script'' to be called each time an interpreter is allocated for use by the '''Ns_TclAllocateInterp''' routine. This is useful for reinitializing resources which may be used during a single transaction in the interpreter.  &lt;br /&gt;
*'''ns_ictl trace deallocate''' ''script''&lt;br /&gt;
: Register ''script'' to be called each time an interpreter is returned after a transaction with the '''Ns_TclDeAllocateInterp''' routine. This is useful for garbage collection, i.e., freeing any resources which may be used during a single transaction in the interpreter.  &lt;br /&gt;
*'''ns_ictl trace getconn''' ''script''&lt;br /&gt;
: Register ''script'' to be called each time an interpreter is returned and associated with an HTTP connection with the '''Ns_GetConnInterp''' routine. This could be useful to define variables relative to the HTTP request.  &lt;br /&gt;
*'''ns_ictl trace freeconn''' ''script''&lt;br /&gt;
: Register ''script'' to be called each time an HTTP connection is closed. This could be used to log information about the request, e.g., timing statistics.  Note that the interpreter may still be actively evaluating a script after the connection is closed, i.e., this is not equivalent to '''ns_ictl trace deallocate''' for connection-related interpreters.  &lt;br /&gt;
*'''ns_ictl update'''&lt;br /&gt;
: This command can be used to atomically compare the epoch of the current duplication script with the epoch of the interpreter, evaluating the script and updating the epoch in the interpreter if they do not match.  This command is generally registered as a callback with '''ns_ictl trace allocate''' by the initialization code.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''INTERPRETER ALLOCATION'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: Tcl interpreter in AOLserver are available on demand with state specific to a virtual server.  These interpreters are also expected to be reused for multiple transactions (e.g., HTTP connections, scheduled procedures, socket callbacks).  &lt;br /&gt;
: To support reuse, AOLserver provides the C-level '''Ns_TclAllocateInterp''' routine to allocate an interpreter from a per-thread cache (creating and initializing a new interpreter if necessary) and the '''Ns_TclDeAllocateInterp''' routine to return an interpreter to the cache when no longer required.  All interpreters in the per-thread cache are destroyed when a thread exists.  &lt;br /&gt;
: In general, only C-level extension writers need to call the C-level API's directly; the various Tcl-level interfaces in AOLserver (e.g., '''ADP''' pages, '''ns_regiseter_proc''', '''ns_schedule_proc''', '''ns_thread''', etc.) allocate and reuse interpreters using the C-level API's automatically before invoking the cooresponding script or ADP page.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''INTERPRETER TRACES'''&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
: To ensure a consistent state of interpreters when allocated and enable cleanup and reinitialization between transactions, each virtual server maintains a list of callbacks to be invoked at various points in the lifetime of an interpreter.  These callbacks are generally installed when the server is initialized at startup and then called automatically by the '''Ns_TclAllocateInterp''' and '''Ns_TclDeAllocateInterp''' API's at the appropriate times and in consistent order.  The '''Ns_TclRegisterTrace''' routine can be used to register C-level callbacks and the '''ns_ictl trace''' command can be used to register Tcl script callbacks.  The '''ns_ictl gettraces''' command can be used to list all currently registered callbacks, both at the Tcl script and C level.  &lt;br /&gt;
: Callbacks registered via the tracing facility are invoked in a specific order depending on the type.  Initialization style callbacks including '''create''', '''allocate''', and '''getconn''' are invoked in FIFO order, with all script callbacks invoked after all C-level callbacks.  This enables extension writers to utilize the facilities of previously initialized extensions. Correspondingly, cleanup style callbacks including '''freeconn''', '''deallocate''', and '''delete''' are invoked in LIFO order, with all scripts callbacks invoked before C-level callbacks. This helps avoid the possibility that a cleanup callback utilizes features of a previously cleaned up extension.  &lt;br /&gt;
: In addition, the '''ns_ictl package''' command can be used to consistently manage the loading of a Tcl package in all interpreters for a virtual server. This feature is mostly a convenience routine built above the generic trace framework with additional checks to ensure version number consistency.  Coupled with '''ns_ictl once''', the '''ns_ictl package''' command provides a clean framework to utilize Tcl packages in multi-threaded AOLserver (see '''EXAMPLES''').  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''VIRTUAL SERVER TCL INITIALIZATION'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: AOLserver also supports a Tcl initialization framework for virtual servers based on callbacks registered by loadable modules and the sourcing of scripts files located in corresponding directories. Options to '''ns_ictl''' to support this framework include ''save'', ''get'', ''epoch'', and ''update'' and are used in conjunction with the generic tracing facility by the virtual server bootstrap script (normally ''bin/init.tcl''). The '''ns_eval''' command also relies on this framework to support dynamic update of the state of interpreters.  &lt;br /&gt;
: This initialization framework pre-dates the Tcl package facilities and utilizes introspection of the state of a startup interpreter at the end of initialization to construct a single script which attempts to duplicate the state in subsequent interpreters.  Steps taken during this initialization include:  &lt;br /&gt;
*1.  Load all modules in the server's module config section, e.g.,&lt;br /&gt;
: ''ns/server/server1/modules''.  Modules with Tcl C-level extensions typically call the legacy '''Ns_TclInitInterps''' routine or the more general '''Ns_TclRegisterTrace''' routine with the ''NS_TCL_TRACE_CREATE'' flag in their module init routine to register a callback to invoke when new interpreters are created. The callback normally creates one or more new commands in the interpreter with '''Tcl_CreateObjCommand''' but may perform any per-interpreter initialization required, e.g., creating and saving private state with the '''Tcl_SetAssocData''' facility.  In addition, as modules are loaded, the string name of the module is added to the list of known modules.  &lt;br /&gt;
*2.  After all C modules are loaded, AOLserver creates a new Tcl&lt;br /&gt;
: interpreter for the virtual server, executing any trace callbacks already registered via the loaded C modules (e.g., any '''Ns_TclInitInterps''' callbacks) and then sources the virtual server bootstrap script, normally ''bin/init.tcl''.  This script creates a few utility procedures and then sources all ''private'' and ''public'' script files in directories which correspond to loaded modules in the order in which they were loaded.  These directories are normally relative to the virtual server and to the AOLserver installation directory, e.g., initialization script files for the module ''mymod'' in the ''server1'' virtual server would be searched for in the ''servers/server1/modules/tcl/mymod/'' and ''modules/tcl/mymod/''.  Any ''init.tcl'' file found in each directory is sourced first with all remaining files sourced in alphabetical order. In addition, any files in the ''public'' directory with identical names to files in the private directory are skipped as a means to enable overloading of specific functionality on a per-server basis.  In practice, most modules only contain shared utility procedures defined in the ''public'' directories and the ''private'' directories are empty or non-existant. The script files normally contain a mix of commands to evaluate once for server configuration (e.g., a call to '''ns_register_proc''' to bind a Tcl procedure to an HTTP request URL) with '''proc''' and '''namespace''' commands to provide additional functionality in the interpreter.  &lt;br /&gt;
*3.  After all script files have been sourced, the bootstrap script&lt;br /&gt;
: code then uses a collection of recursive procedures to extract the definitions of all procedures defined in all namespaces.  The definitions are used to construct a script which attempts to duplicate the state of the initialization interpreters.  This scripts is then saved as the per-virtual server duplication script with the '''ns_ictl save''' command which also increments the ''epoch'' to 1.  There are limits to this approach to determine the full state, e.g., it does not attempt to duplicate any global variables which may have been defined in the startup scripts. Typically, startup scripts will use '''nsv_set''' or other mechanisms to store such shared state.  &lt;br /&gt;
*4.  The bootstrap code then uses the '''ns_ictl trace allocate'''&lt;br /&gt;
: command to register a callback to the '''ns_ictl update''' command each time an interpreter is allocated for use.  In practice, interpreters are created with the default ''epoch'' of 0 and the first call to '''ns_ictl update''' determines an out-of-date condition, evaluates the duplication script, and increments the interpreter's ''epoch'' to 1 to match the state created by the startup interp.  &lt;br /&gt;
*5.  Subsequent calls the '''ns_eval''', if any, will evaluate the&lt;br /&gt;
: given script and then re-generate and save the duplication script as was done at startup, incrementing the ''epoch'' once again. In this way, dynamic updates which are detected in other interpreters on their next call to '''ns_ictl update''' can be supported in a limited fashion.  &lt;br /&gt;
: In practice, while generally successful, this duplication technique has inhibited the clean use of proper Tcl package extensions and encouraged the use of the '''ns_eval''' command which is generally not recommended for the non-deterministic manner in which it attempts to dynamically reconfigure a server.  Also, commands required to configure the server once (e.g., calls to '''ns_register_proc''') are inter-mixed with '''proc''' commands designed to extend functionality in all interpreters, complicating configuration management.  &lt;br /&gt;
: As an alternative, the example below illustrates a means to more explicitly manage configuration through a combination of direct calls to '''ns_ictl trace create''' and '''ns_ictl once'''. Unfortunately, the all encompassing nature of the legacy initialization approach makes it difficult to incrementally move to this cleaner approach because the duplication script construction code is unable to distinguish between state created with the newer, cleaner '''ns_ictl''' commands and state created as a side effect of one or more script files being sourced.  As such, it is expected the legacy initialization framework will remain in place until AOLserver 5.x when it will be removed entirely in a non-backwards compatible move towards the cleaner API's.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''EXAMPLES'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: This example illustrates the use of '''ns_ictl package''' and '''ns_ictl once''' to load an AOLserver-aware Tcl package into a virtual server.  The following code could be added to the virtual server bootstrap script, ''bin/init.tcl'', to load ''MyPkg'' in the virtual server:  &lt;br /&gt;
: &lt;br /&gt;
    &amp;lt;pre&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    #&lt;br /&gt;
    # Startup code in bin/init.tcl:&lt;br /&gt;
    #&lt;br /&gt;
    # Load MyPkg in all interps (including this one).&lt;br /&gt;
    #&lt;br /&gt;
    ns_ictl package require MyPkg&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;/pre&amp;gt;  &lt;br /&gt;
: This call will result in the package being loaded into the startup interpreter in the ordinary Tcl fashion (see the '''package''' man page for details).  Ordinary Tcl extension packages would need no modifications but packages which utilize AOLserver-specific features or require garbage collection between transactions could also use '''ns_ictl''' for finer grained control. For example, the ''init.tcl'' script specified by the '''package ifneeded''' command in the ''MyPkg'' package's ''pkgIndex.tcl'' file could contains:  &lt;br /&gt;
: &lt;br /&gt;
    &amp;lt;pre&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    #&lt;br /&gt;
    # Package code in lib/myPkg1.0/init.tcl:&lt;br /&gt;
    #&lt;br /&gt;
    #&lt;br /&gt;
    &lt;br /&gt;
    package provide MyPkg 1.0&lt;br /&gt;
    &lt;br /&gt;
    #&lt;br /&gt;
    # Server init which will be executed the first time called,&lt;br /&gt;
    # normally in the context of the startup interpreter as above.&lt;br /&gt;
    #&lt;br /&gt;
    &lt;br /&gt;
    ns_ictl once MyPkg {&lt;br /&gt;
        # Register the run Tcl proc HTTP handler.&lt;br /&gt;
        ns_register_proc /mypkg mkpkg::run&lt;br /&gt;
        # Register a garbage collection callback.&lt;br /&gt;
        ns_ictl trace deallocate mypkg::cleanup&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    #&lt;br /&gt;
    # Code which will be invoked to initialize the package in&lt;br /&gt;
    # all interpreters when required.&lt;br /&gt;
    #&lt;br /&gt;
    proc mypkg::run {} {&lt;br /&gt;
        ... handle /mypkg requests ...&lt;br /&gt;
    }&lt;br /&gt;
    proc mkpkg::cleanup {} {&lt;br /&gt;
        ... cleanup transaction resources for mypkg, e.g., db handles ...&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;/pre&amp;gt;  &lt;br /&gt;
: Other examples:&lt;br /&gt;
    % ns_ictl epoch&lt;br /&gt;
    1&lt;br /&gt;
&lt;br /&gt;
    % ns_ictl getmodules&lt;br /&gt;
    nsdb nslog nscp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''SEE ALSO'''&lt;br /&gt;
&lt;br /&gt;
: [[ns_cleanup]], [[ns_init]], [[ns_eval]], [[ns_markfordelete]]&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]] - [[Category:Core Tcl API]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_loop_ctl&amp;diff=5810</id>
		<title>Ns loop ctl</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_loop_ctl&amp;diff=5810"/>
		<updated>2010-06-18T22:31:37Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;manpage&amp;gt;ns_loop_ctl&amp;lt;/manpage&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''NAME'''&lt;br /&gt;
&lt;br /&gt;
: ns_loop_ctl - Replacements for standard Tcl loop commands which enable monitoring and control (new in AOLserver 4.5) (this command was briefly called ns_lctl in some builds)&lt;br /&gt;
&lt;br /&gt;
'''SYNOPSIS'''&lt;br /&gt;
&lt;br /&gt;
: '''ns_loop_ctl''' ''option ?arg?''&lt;br /&gt;
&lt;br /&gt;
'''DESCRIPTION'''&lt;br /&gt;
&lt;br /&gt;
: The '''ns_for''', '''ns_foreach''', and '''ns_while''' commands are replacements for corresponding Tcl commands with the additional capability of monitoring and control through the '''ns_loop_ctl''' command from ''another'' thread. You can either use these commands explicitly or use '''ns_loop_ctl install''' to replace the specified command with one that can be monitored and controlled.&lt;br /&gt;
&lt;br /&gt;
*'''ns_for''' ''start test next body''&lt;br /&gt;
: See the Tcl ''for'' man page for usage. &lt;br /&gt;
*'''ns_foreach''' ''varlist1 list1 ?varlist2 list2 ...? body''&lt;br /&gt;
: See the Tcl ''foreach'' man page for usage. &lt;br /&gt;
*'''ns_while''' ''test body''&lt;br /&gt;
: See the Tcl while man page for usage. &lt;br /&gt;
&lt;br /&gt;
*'''ns_loop_ctl cancel''' ''id''&lt;br /&gt;
: Mark the given loop to cancel at the next iteration, resulting in the loop returning with '''TCL_ERROR'''.  Returns 1 if the loop was successfully marked to be cancelled, 0 otherwise (i.e. loop is no longer running or there was no such loop id to begin with). The error message thrown inside the loop will be &amp;quot;loop canceled&amp;quot;.  Loops can also be cancelled using the [[ns_ictl]] cancel command whose error message is &amp;quot;async cancel&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
*'''ns_loop_ctl eval''' ''id script''&lt;br /&gt;
: Evaluates the provided script inside the loop. This command waits 2 seconds for the target thread to yield control before throwing an error and works best if the loop is first paused. You are able to both read and set any local variables inside the loop to either affect the execution (i.e. set a vwait variable) or introspect the current state of execution for debugging purposes. Note that if the provided script throws an error, this error is caught and its message returned as a string.&lt;br /&gt;
&lt;br /&gt;
*'''ns_loop_ctl info''' ''id''&lt;br /&gt;
: Returns a 6-element list of information about the loop: {loopId threadId loopEnterTime spins status commandAndArgs}, where loopEnterTime is the timestamp in [[ns_time]] get format when the loop was first entered, status is one of &amp;quot;running, paused or canceled&amp;quot; and commandAndArgs is the full command call of the loop (i.e. {while {1} {ns_sleep 1}}).  If ns_while was explicitly used, it will say ns_while, not while.&lt;br /&gt;
&lt;br /&gt;
*'''ns_loop_ctl install''' ''for | foreach | while''&lt;br /&gt;
: Replaces the specified command with the monitored/controlled version for the life of the current interpreter (persists thread allocations).&lt;br /&gt;
&lt;br /&gt;
*'''ns_loop_ctl list'''&lt;br /&gt;
: Returns a list of current loop ids in this virtual server.&lt;br /&gt;
&lt;br /&gt;
*'''ns_loop_ctl pause''' ''id''&lt;br /&gt;
: Mark the given loop to pause at the next iteration. Returns 1 if successfully marked, 0 otherwise.  Pausing an already paused loop also returns 1.&lt;br /&gt;
&lt;br /&gt;
*'''ns_loop_ctl resume''' ''id''&lt;br /&gt;
: Mark the given loop to resume at the next iteration. Returns 1 if successfully marked, 0 otherwise.  Resuming an already running loop also returns 1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''SEE ALSO'''&lt;br /&gt;
:[[ns_ictl]]&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
[[Category:Core Tcl API]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_loop_ctl&amp;diff=5809</id>
		<title>Ns loop ctl</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_loop_ctl&amp;diff=5809"/>
		<updated>2010-06-18T21:59:58Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: Created page with '&amp;lt;manpage&amp;gt;ns_loop_ctl&amp;lt;/manpage&amp;gt;  '''NAME'''  : ns_loop_ctl - Replacements for standard Tcl loop commands which enable monitoring and control (new in AOLserver 4.5) (this command w…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;manpage&amp;gt;ns_loop_ctl&amp;lt;/manpage&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''NAME'''&lt;br /&gt;
&lt;br /&gt;
: ns_loop_ctl - Replacements for standard Tcl loop commands which enable monitoring and control (new in AOLserver 4.5) (this command was briefly called ns_lctl in some builds)&lt;br /&gt;
&lt;br /&gt;
'''SYNOPSIS'''&lt;br /&gt;
&lt;br /&gt;
: '''ns_adp_ctl''' ''option ?bool | arg?''&lt;br /&gt;
&lt;br /&gt;
'''DESCRIPTION'''&lt;br /&gt;
&lt;br /&gt;
: The '''ns_for''', '''ns_foreach''', and '''ns_while''' commands are replacements for corresponding Tcl commands with the additional capability of monitoring and control through the '''ns_loop_ctl''' command. &lt;br /&gt;
*'''ns_for''' ''start test next body''&lt;br /&gt;
: See the Tcl ''for'' man page for usage. &lt;br /&gt;
*'''ns_foreach''' ''varlist1 list1 ?varlist2 list2 ...? body''&lt;br /&gt;
: See the Tcl ''foreach'' man page for usage. &lt;br /&gt;
*'''ns_while''' ''test body''&lt;br /&gt;
: See the Tcl while man page for usage. &lt;br /&gt;
*'''ns_loop_ctl''' ''cancel id''&lt;br /&gt;
: Mark the given loop to cancel at the next iteration, resulting in the loop returning with '''TCL_ERROR'''. &lt;br /&gt;
*'''ns_loop_ctl''' ''eval id script''&lt;br /&gt;
&lt;br /&gt;
'''ns_loop_ctl''' ''info id''&lt;br /&gt;
&lt;br /&gt;
'''ns_loop_ctl''' ''install command''&lt;br /&gt;
&lt;br /&gt;
'''ns_loop_ctl''' ''list''&lt;br /&gt;
&lt;br /&gt;
'''ns_loop_ctl''' ''pause id''&lt;br /&gt;
&lt;br /&gt;
'''ns_loop_ctl''' ''result id''&lt;br /&gt;
&lt;br /&gt;
'''SEE ALSO'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
[[Category:Core Tcl API]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_ictl&amp;diff=5808</id>
		<title>Ns ictl</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=Ns_ictl&amp;diff=5808"/>
		<updated>2010-06-18T21:29:40Z</updated>

		<summary type="html">&lt;p&gt;Akhassin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Man page: http://aolserver.com/docs/tcl/ns_ictl.html&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''NAME'''&lt;br /&gt;
&lt;br /&gt;
: ns_ictl - Manipulate and introspect Tcl interpreter internals&lt;br /&gt;
&lt;br /&gt;
'''SYNOPSIS'''&lt;br /&gt;
&lt;br /&gt;
: '''ns_ictl''' ''option ?arg arg ...?''&lt;br /&gt;
&lt;br /&gt;
'''DESCRIPTION'''&lt;br /&gt;
&lt;br /&gt;
: This command provides access to the internal facilities to control and configure multi-threaded Tcl interpreters in the context of AOLserver virtual servers.  It is normally used in startup initialization scripts to define how new interpreters are initialized when created and to support cleanup and re-initalization between transactions (e.g., HTTP connections).  &lt;br /&gt;
*'''ns_ictl addmodule''' ''module''&lt;br /&gt;
: Add a module to the list of modules to be initialized at startup and returns the new list as the result. This command is not normally required as each module specified in the AOLserver modules config section for the corresponding server (e.g., ''ns/server/server1/modules'') is automatically added to the list.  To be clear, this command simply appens the ''module'' to the list, it doesn't perform any loading of modules.&lt;br /&gt;
*'''ns_ictl cancel''' ''thread''&lt;br /&gt;
: Send an asynchronous interrupt request to the specified thread, cancelling any script currently executing on any AOLserver created interpreter (note the interrupt is not virtual-server specific). This command utilizes the facilities of '''Tcl_AsyncMark''' to mark as ready a callback registered with '''Tcl_AsyncCreate'''. The callback places an error message in the interpreter result and returns '''TCL_ERROR''' to unwind the call stack. The underlying Tcl facility has limitations, e.g., the interrupt will only be noticed when Tcl checks via '''Tcl_AsyncReady''' calls between commands and the interrupt can be caught with a '''catch''' command. See the man page for '''Tcl_AsyncCreate''' for details.  &lt;br /&gt;
*'''ns_ictl cleanup'''&lt;br /&gt;
: This command invokes any callbacks registered during a transaction via the C-level '''Ns_TclRegisterDefer''' routine.  Unlike callbacks registered with the '''ns_ictl trace deallocate''' command or '''Ns_TclRegisterTrace''' routine, these callbacks are executed only once and there is no Tcl-level access to the underlying '''Ns_TclRegisterDefer''' routine.  Currently the only thing that uses this is the C code that releases database handles.  This command is invoked by [[ns_cleanup]] Tcl procedure.&lt;br /&gt;
*'''ns_ictl epoch'''&lt;br /&gt;
: This command returns the unique id for the current duplication script for the virtual server.  The id starts as 0 when the virtual server is created and is incremented each time a new script is saved via the '''ns_ictl save''' command.  &lt;br /&gt;
*'''ns_ictl get'''&lt;br /&gt;
: Return the current duplication script for the virtual server.  This command is useful to view the duplication script created by the initialization script at startup.  &lt;br /&gt;
*'''ns_ictl getmodules'''&lt;br /&gt;
: Return the list of modules to be initialized at startup. This list corresponds to the names of modules specified in the virtual server modules config section, e.g., ''ns/server/server1/modules'' unless additional modules are added via the '''ns_ictl addmodule''' command.  &lt;br /&gt;
*'''ns_ictl gettraces''' ''which''&lt;br /&gt;
: Return the list of traces which will be invoked at the specified time. The ''which'' argument can be one of ''create, delete, allocate, deallocate, getconn'', or ''freeconn''.  The traces are returned in the order in which they will be executed.  Script level traces are returns as strings to evaluate and C-level traces are returned with strings which specify the address of the underlying C procedure and argument.  &lt;br /&gt;
*'''ns_ictl once''' ''key script''&lt;br /&gt;
: Evaluate given script once in the virtual server. The given key is a string name which uniquely identifies the corresponding script. This command is useful in a Tcl package which includes one-time initialization routines, e.g., calls to '''ns_register_proc''' or initialization of shared variables using '''nsv_set''' (see '''EXAMPLES''' below).  &lt;br /&gt;
*'''ns_ictl oncleanup''' ''script''&lt;br /&gt;
: This command is equivalent to '''ns_ictl trace deallocate''' ''script''.  &lt;br /&gt;
*'''ns_ictl oncreate''' ''script''&lt;br /&gt;
: This command is equivalent to '''ns_ictl trace create''' ''script''.  &lt;br /&gt;
*'''ns_ictl ondelete''' ''script''&lt;br /&gt;
: This command is equivalent to '''ns_ictl trace delete''' ''script''.  &lt;br /&gt;
*'''ns_ictl oninit''' ''script''&lt;br /&gt;
: This command is equivalent to '''ns_ictl trace allocate''' ''script''.  &lt;br /&gt;
*'''ns_ictl package''' ''?-exact? package ?version?''&lt;br /&gt;
: This command is used to require a package in the calling interpreter and, if successfully loaded, it will require the exact same version in all other interpreters for the virtual server. If version consistency is not important, you can achieve the same effect with '''ns_ictl trace allocate''' {package require ''package''}. In addition, allocate too frequent for most packages.  Package state is retained between thread allocations in a given interpreter, so at startup, doing ns_ictl oninit {package require ''package''} should be sufficient and will also work in AOLserver 4.0.  This option can be useful, however, if you want to alter the state of already created interpreters at runtime.&lt;br /&gt;
*'''ns_ictl runtraces''' which''&lt;br /&gt;
: This command runs the requested traces. The ''which'' argument must be one of '''create''', '''delete''', '''allocate''', '''deallocate''', '''getconn''', or '''freeconn'''.  Direct calls to this command are not normally necessary as the underlying C code will invoke the callbacks at the required times.  Exceptions include calling '''ns_ictl runtraces''' or testing purposes or to mimic the normal cleanup and initialization work performed on between transactions in a long running thread (see '''EXAMPLES''' below).  &lt;br /&gt;
*'''ns_ictl save''' ''script''&lt;br /&gt;
: Save the given script as the duplication script, incrementing the virtual server epoch number.  This command is normally called by the bootstrap script after constructing the script to duplicate the procedures defined by sourcing the various module initialization script files.  It's also used by [[ns_eval]] to dynamically update the interpreter 'template'.&lt;br /&gt;
*'''ns_ictl threads'''&lt;br /&gt;
: Return a list of all threads with interpreters for the virtual server. The ids return are small strings which represent the underlying thread ids and can be passed to the '''ns_ictl cancel''' command to send an asynchronous cancel request.  &lt;br /&gt;
*'''ns_ictl trace create''' ''script''&lt;br /&gt;
: Register ''script'' to be called when an interpreter is first created. This is useful to create procedures, require packages, or initialize other state to be used during the lifetime of the interpreter.  &lt;br /&gt;
*'''ns_ictl trace delete''' ''script''&lt;br /&gt;
: Register ''script'' to be called before an interpreter is destroyed. This is useful to free any resources which may have been allocated for the interpreter during the lifetime of the interpreter.  &lt;br /&gt;
*'''ns_ictl trace allocate''' ''script''&lt;br /&gt;
: Register ''script'' to be called each time an interpreter is allocated for use by the '''Ns_TclAllocateInterp''' routine. This is useful for reinitializing resources which may be used during a single transaction in the interpreter.  &lt;br /&gt;
*'''ns_ictl trace deallocate''' ''script''&lt;br /&gt;
: Register ''script'' to be called each time an interpreter is returned after a transaction with the '''Ns_TclDeAllocateInterp''' routine. This is useful for garbage collection, i.e., freeing any resources which may be used during a single transaction in the interpreter.  &lt;br /&gt;
*'''ns_ictl trace getconn''' ''script''&lt;br /&gt;
: Register ''script'' to be called each time an interpreter is returned and associated with an HTTP connection with the '''Ns_GetConnInterp''' routine. This could be useful to define variables relative to the HTTP request.  &lt;br /&gt;
*'''ns_ictl trace freeconn''' ''script''&lt;br /&gt;
: Register ''script'' to be called each time an HTTP connection is closed. This could be used to log information about the request, e.g., timing statistics.  Note that the interpreter may still be actively evaluating a script after the connection is closed, i.e., this is not equivalent to '''ns_ictl trace deallocate''' for connection-related interpreters.  &lt;br /&gt;
*'''ns_ictl update'''&lt;br /&gt;
: This command can be used to atomically compare the epoch of the current duplication script with the epoch of the interpreter, evaluating the script and updating the epoch in the interpreter if they do not match.  This command is generally registered as a callback with '''ns_ictl trace allocate''' by the initialization code.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''INTERPRETER ALLOCATION'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: Tcl interpreter in AOLserver are available on demand with state specific to a virtual server.  These interpreters are also expected to be reused for multiple transactions (e.g., HTTP connections, scheduled procedures, socket callbacks).  &lt;br /&gt;
: To support reuse, AOLserver provides the C-level '''Ns_TclAllocateInterp''' routine to allocate an interpreter from a per-thread cache (creating and initializing a new interpreter if necessary) and the '''Ns_TclDeAllocateInterp''' routine to return an interpreter to the cache when no longer required.  All interpreters in the per-thread cache are destroyed when a thread exists.  &lt;br /&gt;
: In general, only C-level extension writers need to call the C-level API's directly; the various Tcl-level interfaces in AOLserver (e.g., '''ADP''' pages, '''ns_regiseter_proc''', '''ns_schedule_proc''', '''ns_thread''', etc.) allocate and reuse interpreters using the C-level API's automatically before invoking the cooresponding script or ADP page.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''INTERPRETER TRACES'''&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
: To ensure a consistent state of interpreters when allocated and enable cleanup and reinitialization between transactions, each virtual server maintains a list of callbacks to be invoked at various points in the lifetime of an interpreter.  These callbacks are generally installed when the server is initialized at startup and then called automatically by the '''Ns_TclAllocateInterp''' and '''Ns_TclDeAllocateInterp''' API's at the appropriate times and in consistent order.  The '''Ns_TclRegisterTrace''' routine can be used to register C-level callbacks and the '''ns_ictl trace''' command can be used to register Tcl script callbacks.  The '''ns_ictl gettraces''' command can be used to list all currently registered callbacks, both at the Tcl script and C level.  &lt;br /&gt;
: Callbacks registered via the tracing facility are invoked in a specific order depending on the type.  Initialization style callbacks including '''create''', '''allocate''', and '''getconn''' are invoked in FIFO order, with all script callbacks invoked after all C-level callbacks.  This enables extension writers to utilize the facilities of previously initialized extensions. Correspondingly, cleanup style callbacks including '''freeconn''', '''deallocate''', and '''delete''' are invoked in LIFO order, with all scripts callbacks invoked before C-level callbacks. This helps avoid the possibility that a cleanup callback utilizes features of a previously cleaned up extension.  &lt;br /&gt;
: In addition, the '''ns_ictl package''' command can be used to consistently manage the loading of a Tcl package in all interpreters for a virtual server. This feature is mostly a convenience routine built above the generic trace framework with additional checks to ensure version number consistency.  Coupled with '''ns_ictl once''', the '''ns_ictl package''' command provides a clean framework to utilize Tcl packages in multi-threaded AOLserver (see '''EXAMPLES''').  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''VIRTUAL SERVER TCL INITIALIZATION'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: AOLserver also supports a Tcl initialization framework for virtual servers based on callbacks registered by loadable modules and the sourcing of scripts files located in corresponding directories. Options to '''ns_ictl''' to support this framework include ''save'', ''get'', ''epoch'', and ''update'' and are used in conjunction with the generic tracing facility by the virtual server bootstrap script (normally ''bin/init.tcl''). The '''ns_eval''' command also relies on this framework to support dynamic update of the state of interpreters.  &lt;br /&gt;
: This initialization framework pre-dates the Tcl package facilities and utilizes introspection of the state of a startup interpreter at the end of initialization to construct a single script which attempts to duplicate the state in subsequent interpreters.  Steps taken during this initialization include:  &lt;br /&gt;
*1.  Load all modules in the server's module config section, e.g.,&lt;br /&gt;
: ''ns/server/server1/modules''.  Modules with Tcl C-level extensions typically call the legacy '''Ns_TclInitInterps''' routine or the more general '''Ns_TclRegisterTrace''' routine with the ''NS_TCL_TRACE_CREATE'' flag in their module init routine to register a callback to invoke when new interpreters are created. The callback normally creates one or more new commands in the interpreter with '''Tcl_CreateObjCommand''' but may perform any per-interpreter initialization required, e.g., creating and saving private state with the '''Tcl_SetAssocData''' facility.  In addition, as modules are loaded, the string name of the module is added to the list of known modules.  &lt;br /&gt;
*2.  After all C modules are loaded, AOLserver creates a new Tcl&lt;br /&gt;
: interpreter for the virtual server, executing any trace callbacks already registered via the loaded C modules (e.g., any '''Ns_TclInitInterps''' callbacks) and then sources the virtual server bootstrap script, normally ''bin/init.tcl''.  This script creates a few utility procedures and then sources all ''private'' and ''public'' script files in directories which correspond to loaded modules in the order in which they were loaded.  These directories are normally relative to the virtual server and to the AOLserver installation directory, e.g., initialization script files for the module ''mymod'' in the ''server1'' virtual server would be searched for in the ''servers/server1/modules/tcl/mymod/'' and ''modules/tcl/mymod/''.  Any ''init.tcl'' file found in each directory is sourced first with all remaining files sourced in alphabetical order. In addition, any files in the ''public'' directory with identical names to files in the private directory are skipped as a means to enable overloading of specific functionality on a per-server basis.  In practice, most modules only contain shared utility procedures defined in the ''public'' directories and the ''private'' directories are empty or non-existant. The script files normally contain a mix of commands to evaluate once for server configuration (e.g., a call to '''ns_register_proc''' to bind a Tcl procedure to an HTTP request URL) with '''proc''' and '''namespace''' commands to provide additional functionality in the interpreter.  &lt;br /&gt;
*3.  After all script files have been sourced, the bootstrap script&lt;br /&gt;
: code then uses a collection of recursive procedures to extract the definitions of all procedures defined in all namespaces.  The definitions are used to construct a script which attempts to duplicate the state of the initialization interpreters.  This scripts is then saved as the per-virtual server duplication script with the '''ns_ictl save''' command which also increments the ''epoch'' to 1.  There are limits to this approach to determine the full state, e.g., it does not attempt to duplicate any global variables which may have been defined in the startup scripts. Typically, startup scripts will use '''nsv_set''' or other mechanisms to store such shared state.  &lt;br /&gt;
*4.  The bootstrap code then uses the '''ns_ictl trace allocate'''&lt;br /&gt;
: command to register a callback to the '''ns_ictl update''' command each time an interpreter is allocated for use.  In practice, interpreters are created with the default ''epoch'' of 0 and the first call to '''ns_ictl update''' determines an out-of-date condition, evaluates the duplication script, and increments the interpreter's ''epoch'' to 1 to match the state created by the startup interp.  &lt;br /&gt;
*5.  Subsequent calls the '''ns_eval''', if any, will evaluate the&lt;br /&gt;
: given script and then re-generate and save the duplication script as was done at startup, incrementing the ''epoch'' once again. In this way, dynamic updates which are detected in other interpreters on their next call to '''ns_ictl update''' can be supported in a limited fashion.  &lt;br /&gt;
: In practice, while generally successful, this duplication technique has inhibited the clean use of proper Tcl package extensions and encouraged the use of the '''ns_eval''' command which is generally not recommended for the non-deterministic manner in which it attempts to dynamically reconfigure a server.  Also, commands required to configure the server once (e.g., calls to '''ns_register_proc''') are inter-mixed with '''proc''' commands designed to extend functionality in all interpreters, complicating configuration management.  &lt;br /&gt;
: As an alternative, the example below illustrates a means to more explicitly manage configuration through a combination of direct calls to '''ns_ictl trace create''' and '''ns_ictl once'''. Unfortunately, the all encompassing nature of the legacy initialization approach makes it difficult to incrementally move to this cleaner approach because the duplication script construction code is unable to distinguish between state created with the newer, cleaner '''ns_ictl''' commands and state created as a side effect of one or more script files being sourced.  As such, it is expected the legacy initialization framework will remain in place until AOLserver 5.x when it will be removed entirely in a non-backwards compatible move towards the cleaner API's.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''EXAMPLES'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: This example illustrates the use of '''ns_ictl package''' and '''ns_ictl once''' to load an AOLserver-aware Tcl package into a virtual server.  The following code could be added to the virtual server bootstrap script, ''bin/init.tcl'', to load ''MyPkg'' in the virtual server:  &lt;br /&gt;
: &lt;br /&gt;
    &amp;lt;pre&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    #&lt;br /&gt;
    # Startup code in bin/init.tcl:&lt;br /&gt;
    #&lt;br /&gt;
    # Load MyPkg in all interps (including this one).&lt;br /&gt;
    #&lt;br /&gt;
    ns_ictl package require MyPkg&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;/pre&amp;gt;  &lt;br /&gt;
: This call will result in the package being loaded into the startup interpreter in the ordinary Tcl fashion (see the '''package''' man page for details).  Ordinary Tcl extension packages would need no modifications but packages which utilize AOLserver-specific features or require garbage collection between transactions could also use '''ns_ictl''' for finer grained control. For example, the ''init.tcl'' script specified by the '''package ifneeded''' command in the ''MyPkg'' package's ''pkgIndex.tcl'' file could contains:  &lt;br /&gt;
: &lt;br /&gt;
    &amp;lt;pre&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    #&lt;br /&gt;
    # Package code in lib/myPkg1.0/init.tcl:&lt;br /&gt;
    #&lt;br /&gt;
    #&lt;br /&gt;
    &lt;br /&gt;
    package provide MyPkg 1.0&lt;br /&gt;
    &lt;br /&gt;
    #&lt;br /&gt;
    # Server init which will be executed the first time called,&lt;br /&gt;
    # normally in the context of the startup interpreter as above.&lt;br /&gt;
    #&lt;br /&gt;
    &lt;br /&gt;
    ns_ictl once MyPkg {&lt;br /&gt;
        # Register the run Tcl proc HTTP handler.&lt;br /&gt;
        ns_register_proc /mypkg mkpkg::run&lt;br /&gt;
        # Register a garbage collection callback.&lt;br /&gt;
        ns_ictl trace deallocate mypkg::cleanup&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    #&lt;br /&gt;
    # Code which will be invoked to initialize the package in&lt;br /&gt;
    # all interpreters when required.&lt;br /&gt;
    #&lt;br /&gt;
    proc mypkg::run {} {&lt;br /&gt;
        ... handle /mypkg requests ...&lt;br /&gt;
    }&lt;br /&gt;
    proc mkpkg::cleanup {} {&lt;br /&gt;
        ... cleanup transaction resources for mypkg, e.g., db handles ...&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;/pre&amp;gt;  &lt;br /&gt;
: Other examples:&lt;br /&gt;
    % ns_ictl epoch&lt;br /&gt;
    1&lt;br /&gt;
&lt;br /&gt;
    % ns_ictl getmodules&lt;br /&gt;
    nsdb nslog nscp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''SEE ALSO'''&lt;br /&gt;
&lt;br /&gt;
: [[ns_cleanup]], [[ns_init]], [[ns_eval]], [[ns_markfordelete]]&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]] - [[Category:Core Tcl API]]&lt;/div&gt;</summary>
		<author><name>Akhassin</name></author>
		
	</entry>
</feed>