ACS Documentation : ACS Core Architecture Guide : ACS Request Processor
/web/arsdigita/www to the URL,
serving up the file named by that path.
This is no longer the case: the process of responding to a request involves many more steps than simply resolving a path and delivering a file. Serving an ACS page involves (at the very least) reading security information from HTTP cookies, extracting subcommunity information from the URL, calling filters and registered procedures, invoking the abstract URL system to determine which file to serve, and then actually serving the file.
The traditional way to realize this process was to register a plethora of filters and
procedures using ns_register_filter and ns_register_proc,
but there were several problems with this approach:
/www directory), as in
the case of pages associated with packages.
ns_register_procs for each possible URL prefix
(/groups, /some-group-type,
/some-group-name, etc.).
/download/files/ wouldn't work for requests under
/groups/some-group-name/download/files/62/smug.jpg.
ns_register_filter
and ns_register_proc are deprecated. They are replaced by
ad_register_filter and ad_register_proc
which have similar syntaxes but support filter priorities.
ns_register_filter
and ns_register_proc API calls - using them results in an error
(unless called directly by request processor code).
ad_register_filter and ad_register_proc, their replacements,
don't actually register anything immediately when invoked.
Instead they just build up a list,
in NSV arrays, of filters and procedures.
After server initialization, the request processor examines the list of
registered filters, sorts them by priority, and registers them with AOLserver
using ns_register_filter. It also registers rp_handler
as the very first filter to run.
When the request processor uses ns_register_filter to register
those filters in the ad_register_filter list, it doesn't
call ns_register_filter with literally the same procedure name as
was provided to ad_register_filter. Instead, it registers
the rp_invoke_filter wrapper, which does a few things before
dispatching to the handler procedure:
bboard package has registered a filter
for /bboard/view-attachment/*, and the URL being requested is
/users/jsalz/bboard/view-attachment/3.html, and the bulletin-board
package is disabled for the /users/jsalz subsite, then the filter
will not be invoked.
catch
statement, so a reasonable error message is displayed if the filter throws an error
or returns an invalid result.
rp_invoke_proc to invoke registered procedures.
rp_handler filter:
ad_conn global variable,
which contains information about the connection (see
ad_conn below).
/users/jsalz/address-book/ belongs to
jsalz's subsite), strip the subsite information from the URL
and save it in the environment to be later accessed by ad_conn.
If no subsite is specified, then the URL is assumed to correspond to the
main subsite (the subsite belonging to the_public object).
After this step, ns_conn url returns the modified URL
(without the subsite prefix).
*-procs.tcl files,
source them.
Also examine any files registered to be watched (via the package manager);
if any have been changed, source them as well.
Host header to make
sure it's what we expect it to be. If the Host header is present
but differs from the canonical server name (as reported by ns_info
location), issue an HTTP redirect using the the correct, canonical
server name.
For instance, if someone accesses the URL
http://arsdigita.com/pages/customers, we redirect them to
http://www.arsdigita.com/pages/customers since the canonical
host name for the server is www.arsdigita.com, not
arsdigita.com.
Security handling. (Skipped for system URLs.)
Examine the security cookies, ad_browser_id
and ad_session_id. If either is is invalid or not present at all,
issue a cookie and note information about the new browser or session in the
database.
ad_register_filter and ad_register_proc are
executed. Their paths are matched the URL with subsite information stripped,
e.g., a filter registered for /bboard/view-attachments is
executed for a URL of the form /users/jsalz/bboard/view-attachments/3.html
(provided that the bulletin-board package is enabled for that subsite).
If no filter returns filter_return and no
registered procedure matches, then the abstract URL system is invoked to resolve
the URL to a file:
rp_register_directory_map, map to the associated directory
in the filesystem. For example, if we've called
then all requests under therp_register_directory_map "apm" "acs-kernel" "apm-docs"
/apm URL stub are mapped to
the acs-kernel package directory www/apm-docs,
and all requests under /admin/apm are mapped to the
acs-kernel package directory admin-www/apm-docs.
www or
admin-www directory in that package. For example, if
there's a package named address-book, then
requests under /address-book are mapped to the
/packages/address-book/www directory, and requests under
/admin/address-book are mapped to
/packages/address-book/admin-www.
/web/arsdigita/www) to the URL, just like AOLserver
always used to do.
Now check to see if the path refers to a directory without a trailing
slash, e.g. a request to http://www.arsdigita.com/address-book.
If this is the case, issue a redirect to the directory with the trailing
slash, e.g. http://www.arsdigita.com/address-book/. This is
necessary so the browser will properly resolve relative HREFs.
Next determine which particular file to serve. If our file name is
filename, check to see if any files exist which are named
filename.*, i.e. we try automatically adding an extension to the
file name. If the URL ends in a trailing slash, then no file name is provided
so we look for an index.* file instead.
Give precedence to particular extensions in the order specified
by the ExtensionPrecedence parameter, e.g. in general
prefer to serve .tcl files rather than .adp
files.
.tcl) file, source it;
if it's an ADP (.adp) file, parse it.
rp_register_extension_handler, use that handler to serve
the file. For example, if I call
then if the file is a JSP (rp_register_extension_handler jsp jsp_handler
.jsp) file, the jsp_handler
routine will be called and expected to return a page.
ns_register_filter and ns_register_proc are
dead - trying to use them causes an error. Instead of these two procedures, you'll need
to use ad_register_filter and ad_register_proc, drop-in
replacements which provide the same functionality but are integrated into the request
processor.
ad_register_filter when method URLpattern script [ args ... ]
ad_register_proc [ -noinherit f ] method URL procname [ args ... ]
ns_register_filter and ns_register_proc.
See the AOLserver
documentation for syntax.
ad_script_abort
return -code return,
except that it works in any stack frame.
ad_conn which
ns_conn). Allowed values for which are:
url: same as ns_conn url.
(In future versions of ACS with subcommunity support,
this will return the portion of the URL after any subcommunity
information. For instance, for a URL request to
/groups/Boston/address-book/, it would return
/address-book/.)
canonical_url: returns a URL, minus extension,
which is consistent
no matter what URL is used to access a resource. For instance, if any
of the following URLs are used to access the address book:
Boston office:
then the canonical URL for each might be/address-book/ /address-book/index /address-book/index.tcl
This URL is useful whenever a consistent, unique identifier for a resource is necessary, e.g. storing URLs for general comments./address-book/index
full_url: similar to ad_conn canonical_url,
except that the extension of the file is included. For instance, in the case of
the example above, ad_conn full_url would return
/address-book/index.tcl
file: returns the absolute path in the filesystem
of the file which is being delivered. If the request does not correspond
to a file (e.g. is a registered filter or procedure), returns an empty string.
extension: returns the extension of the file
which is being delivered (equivalent to [file extension [ad_conn file]]).
If the request does not correspond to a file (e.g. is a registered filter or procedure),
returns an empty string.
browser_id: returns the client's browser ID
(see the document security and session-tracking).
session_id: returns the client's session ID
(see the document security and session-tracking).
subsite_id: returns the ID of the subsite for
the current connection.
subsite_object_id: returns the ID of the object which is
the context of the subsite for the current connection.
real_url: returns the actual URL, including subcommunity
information, specified by the request. This is necessary since the request
processor strips subcommunity information from [ns_conn url] so that
filters and registered procedures work properly.
[ns/server/yourservername/request-processor] ; log lots of timestamped debugging messages? DebugP=0 ; URL sections exempt from Host header checks and security/session handling. ; (can specify an arbitrary number). SystemURLSection=SYSTEM ; precedence for file extensions, e.g., "tcl,adp,html" means "serve ; a .tcl file if available, else an .adp file if available, else an ; .html file if available, else the first file available in alphabetical ; order". Comma-separated. ExtensionPrecedence=tcl,adp,html,jpg,gif
ns_register_filters and
ns_register_procs), allowing us a great deal of control over exactly what
happens when we deliver a response to an HTTP request. We also introduced new APIs,
ad_register_filter and ad_register_proc, analogous to existing
AOLserver APIs (ns_register_filter and ns_register_proc) but tightly
integrated into the request processor.
However, Tcl is slower than C and many people questioned the wisdom of essentially
porting so much of AOLserver's functionality into Tcl. In ACS 4.0 we add a C module
to AOLserver, nsrewrite, allowing us to rewrite URLs for subsites (so that
ns_register_filter and ns_register_proc can work properly)
and implement the request processor using the ns_* primitives instead of
handling every request ourselves in Tcl.
ns_register_filter and ns_register_proc are still deprecated -
we maintain the ad_register_filter and ad_register_proc
abstractions (and continue to require their use) so we can handle filter priorities,
provide debugging support, and facilitate the use of templating at any stage of the
request process (e.g., even in a filter returning filter_return).
Last Modified: request-processor-3.x.html,v 1.1 2001/01/21 01:38:18 bquinn Exp