SREhttp/2 Manual||
Attributes
SREhttp/2 Selector-Specific Advanced Options
Abstract: |
SREhttp/2's selector-specific "advanced options" are used for a variety
of purposes, including setting parameters, enabling less-frequently
used options, and executing mid-filter procedures.
|
---|
Contents:
SREhttp/2's selector specific advanced-options provides a set of
less-frequently needed, "advanced-options" to the ambitious webmaster.
These advanced-options include:
- execution of EXEC ("mid-filter") procedures,
- customization of response headers
- suppression of specific server side includes.
- selector specific mime type
- selector specific replacement-rules
- set the EXPIRES, MD5, PRE_RESPONSE, POST_RESPONSE and other parameters
- specify the maximum number of simultaneous users of a resource
- modifying the realm's attributes on a client specific basis
- in the future, additional features may be added.
Selector-specific advanced options are assigned in the (default
or a host-specific) ATTRIBS.CFG file. There are two keywords in
ATTRIBS.CFG that can be used to assign advanced-options:
OPTION and OPTION_FILE.
The two are equivalent, with the advanced-options specified
in an OPTION_FILE having the same syntax as an advanced-options
specified using OPTION.
Notes:
Example of entries in ATTRIBS.CFG:
REALM: Myrealm
RULE: /SAMPLES/*
Option: header add X-Grader: this is a mediocre resource
Option: set expires 0.1
Realm: HerRealm
Rule: /VIOLET/*
Option_file: cfg/her_opts.opt
Example of OPTION_FILE:
header: add X-Confirm: 13
ssi_no code
set pre_response 0
Note: | The examples in this document assume that one is creating
an OPTION_FILE. If, instead, you are adding options directly to an ATTRIBS.CFG file,
you should simply add Option: to the begining of the examples.
For example:
- header X-Size-1: this is $size size
would be written to ATTRIBS.CFG as Option: header X-Size-1: this is $size size
- ssi_no header footer
would be written to ATTRIBS.CFG as Option: ssi_no header footer
|
---|
There are several types of selector-specific advanced options:
- EXEC procedures -- execute an external REXX procedure.
- HEADER and RESPONSE directives -- specify a custom response header
- SSI_suppression directives -- suppress specific SSI actions.
- Set MIME type
- Replacement rules
- Set a few variables
- Controlling the maximum number of simultaneous users of a resource
- Modifying a realm's attributes on a client specific basis
The following documents how to use these options. We also recommend perusing
the ADV_OPTS.CTL and EXEC_SMP.REXsample files.
EXEC commands can be thought of as a mid-filter hook.
EXEC is used to execute external REXX procedures that are run
by SREhttp/2 before the (optional) pre-response procedure.
As detailed in OUTLINE.HTM, request processing involves these steps:
- The SRE2003 "pre-transaction" procedure
- The SRE2003 "pre-request" procedure
- The fast-filter
- Invoking SREhttp/2...
- SREhttp/2 EXEC procedures
- SREhttp/2 "pre-response" procedure
- SRE2003 "IM" procedures
- The SREhttp/2 "post-response" procedure
Note EXEC procedures are called after redirection directives
and access controls are applied, but before an actual redirection response
(say, a 301 response) is returned to the client.
Syntax:
EXEC filename opt_string
where:
| filename:
| a filename of the rexx procedure to execute. |
| opt_string: | an optional argument sent to "filename" (when it
is called)
|
Examples:
EXEC EXEC_SMP.REX Hello from job 1.
EXEC !MY_EXEC This is my exec
The EXEC procedure will be sent a set of variables:
ARGUMENT |
The "argument" following the procedure-file name. This may contain
commas (a comma containing ARGUMENT does not result in multiple
arguments being sent to the called procedure).
In the above example, ARGUMENT would be Hello from job 1.
|
SOURCE |
The SRE2003 source argument
|
REQUEST |
The SRE2003 request argument
For example: GET /test1? HTTP/1.0
|
SELUSE |
The (SREhttp/2) modified selector
(after redirection &
~ replacement)
|
SERVERNAME |
The name of the server that this request was sent to
|
HOST_NICKNAME |
SREhttp/2 host nickname
for the server processing this request
|
DataDir |
The (possibly host-specific) HTML documents,
& other web-accessible files, data-directory
|
PRIVSET |
The client-privileges assigned to this client
|
ID_INFO |
The ID_INFO parameter
|
Note: the EXEC procedure can read these arguments using:
parse arg anarg,source,request,seluse2,servername,host_nickname,datadir,privset,id_info
An EXEC procedure can return either:
- if the EXEC procedure sends a response directly to the client using SRE_COMMAND,
then the EXEC procedure must return the status code returned by SRE_COMMAND
(i.e.; rcode=sre_command('FILE .....'); return rcode ).
- Otherwise, EXEC procedures should return nothing (i.e.; return ' ').
Notes:
- If the "filename" starts with a ! (as in the !MY_EXEC example),
the name (minus the starting !) is assumed to be that of a procedure
that has been loaded using the LOAD_EXEC
option in the PRELOADS.CFG file.
If no such procedure name has been loaded, a 500 error occurs.
- If not fully qualfied, filename is assumed to be
relative to the SREHTTP2\PROCS directory.
- EXEC_SMP.REX (in the SREHTTP2\PROCS directory) contains a simple
example of such an external procedure.
- MAX_USER.REX (in the SREHTTP2\PROCS directory) is an EXEC procedure used to control the
maximum number of simultaneous users of a resource; where a resource is a single selector, or a set of selectors.
- Hint: one use of EXEC is to support HTTP M-extensions,
as described in the
HTTP Extensions RFC.
Otherwise, these M-extensions will result in a 510 error return.
You can include HEADER and RESPONSE entries -- they will be used
almost verbatim by SRE2003.
This response header customization is only available for GET and HEAD
requests that invoke a file transfer (including HTML documents
with server side includes).
That is, for "server side processing" requests (such as CGI-BIN
scripts, SREhttp/2 addons, PUT and DELETE requests, and imagemaps)
HEADER and RESPONSE entries will not be used.
As a convenience, SREhttp/2 will perform a few substitutions on HEADER
and RESPONSE entries:
$GMT | | The current GMT day, date and time.
|
$SERVERNAME | | The "site name" to which the request was sent
|
$SIZE | | The number of bytes to be sent
|
$CODE | | The status code (almost always 200)
|
Examples:
response HTTP/1.1 406 Variant not available
header X-Webmaster-Name: Daniel Platypus
header drop expires
header X-comment: X- headers are created by SREhttp/2
header X-Our-server: $servername
header X-Size-1: this is $size size
header X-Code-1: this is $code code
Notes:
- Headers specified using advanced options override automatically
generated headers. For example, if a cache-control header
is specified as an advanced option, then the automatically
generated cache-control header will not be used.
- The HEADER DROP will drop a header (if one exists). This is
cumulative, so that...
HEADER DROP X-EXPIRES
HEADER ADD X-Expires: not-now
yields an
X-Expires: not-now
response header.
- See the description of SRE_COMMAND for
details on HEADER and RESPONSE SRE2003
directives.
- Note that the HEADER selector-specific option refers to
response headers. In contrast, the HEADER
SSI_VAR variable refers to text inserted into the top of an HTML document.
Although you can suppress all server side includes
(either for all documents, or on a selector-specific basis), you may wish to
only suppress a select set of these includes.
In particular, you may wish to supress HEADERS and FOOTERS
for a portion of your HTML documents. This can be easily done with
the various server side include suppression options.
Syntax:
SSI_NO opt1 ... optn
The available OPTn options are:
replace_rules | do not use the replace-rules |
|
cache | suppress caching (similar to a <-- CACHE NO --> keyphrase)
|
footer | Do NOT include FOOTERS lines
|
header | Do NOT include HEADERS lines
|
include | Do NOT process <-- INCLUDE filename --> keyphrases
|
interpret | Do NOT process <-- INTERPRET FILE filename --> or
<-- INTERPRET CODE xxx ;yyy --> keyphrases.
|
replace | Do NOT process <-- REPLACE varname --> keyphrases
|
select | Do NOT process <-- SELECT xxx --> ... <-- SELECT END -->
keyphrases
keyphrases
|
#config | Do NOT process <-- #CONFIG ... --> keyphrases
|
#echo | Do NOT process <-- #ECHO ... --> keyphrases
|
#exec | Do NOT process <-- #EXEC ... --> keyphrases
|
#filestat | Do NOT process <-- #FLASTMOD ... --> or <-- #FSIZE ... -->
|
#include | Do NOT process <-- #INCLUDE ... --> keyphrases
|
#if | Do NOT process <-- #IF ... --> keyphrases
|
#set | Do NOT process <-- #SET ... --> keyphrases
|
|
Notes: |
- You can include several options on several lines (multiple SSI_NO lines, within
a realm defintion, are concatenated).
- SSIs are only processed for text/html documents that either:
- End with one of the SSI_EXTENSIONS
- Have a DO_SSI permission
|
Examples:
ssi_no cache
ssi_no header footer
ssi_no select #echo #exec
You can specify the mime type for this (these) selector(s).
Just enter:
MIME type/subtype
For example:
MIME text/plain
MIME image/jpg
You should have, at most, one MIME line per selector (latter entries are
ignored).
You can specify selector specific "replacement rules". If specified, these
replace the host-specific SSI replacement rules.
The syntax is:
REPLACE old_string==new_string
Notes:
Examples:
REPLACE $(==<!-- $ customiz
REPLACE )$== -->
Notes:
- If any selector-specific replacement rules are defined,
then the generic (host-specfic) replacement rules are ignored
(for requests that match selectors for which replacement rules
are defined).
-
Hint: Using Replacement rules and Load Balancing.
-
Replace rules can come in handy when you are load balancing to subsidiary-
sites. In order to guarantee that all requests pass through a main-site,
you may have to include a <BASE href="main.site.url"> element in the
<HEAD> section of HTML documents on subsidiary-sites. Since adding these
elements may be tedious, the following REPLACE can be used instead:
REPLACE </HEAD>==<BASE href="http://main.site.url"> </HEAD>
where main.site.url should be the IP address of the main-site.
You can set several SREhttp/2 variables on a request specific basis.
These are:
CHARSET | add a charset=xxx to the Content-Type response header
|
DEFAULTS | a list of default index files to use (if no file specified)
|
EMPTY_PATH_OKAY | allow an empty PATH_INFO cgi-bin environment variable
|
ENABLE_CGI_PIECES | allow, or suppress, sending CGI-BIN output
in pieces (as it becomes available)
|
ETAG | specify an etag, or how to auto-create an etag
|
EXPIRES | add an offset to an otherwise immediate expiration
|
GET_PRIVS | force SREhttp/2 to obtain client privileges
|
IM | disable or specify Instance Manipulation
|
LIMITtimeINACTIVE | number of inactive seconds to grant this request to finish
|
LIMITtimeTOTAL | number of seconds to allow this request to finish
|
MD5 | add an Content-MD5 response header
|
NOTIFY_MESSAGE | message used in a NOTIFY redirection
|
POST_RESPONSE | suppress the use of "post-response" procedure(s)
|
PRE_RESPONSE | suppress the use of a "pre-response" procedure, or specify
a message to send to a pre-response procedure
|
PUT_OVERWRITE | Allow PUT method requests to overwrite files of the same name.
|
DYNPRIV_DURATION | Duration of dynamic privileges, in minutes.
|
The syntax to use is:
SET varname value
Some examples:
SET ENABLE_CGI_PIECES 0
SET ETAG SIMPLE
SET ETAG AUTO2
SET ETAG "eT9fdty"
SET EXPIRES 0 (do not add an offset)
SET EXPIRES 0.66 (add a 0.66 day offset)
SET LIMITtimeTOTAL 150 (allow 150 seconds to complete response)
SET LIMITtimeINACTIVE 50 (allow 50 seconds of inactive time)
SET PRE_RESPONSE 0
SET PRE_RESPONSE ENCRYPT SRE_A
SET PRE_RESPONSE DEFAULT
SET POST_RESPONSE Class=Red Cars
SET PUT_OVERWRITE 1
SET IM 0 (0 means disable)
SET IM DELTA
SET MD5 0 (suppress generation of Content-MD5 header)
SET MD5 1 (add a Content-MD5 header)
SET NOTIFY_MESSAGE Or, you can try <a href="altpage.htm">an alternative</a>
SET DYNPRIV_DURATION 35
the details ... |
---|
CHARSET |
For documents with a Content-Type of text/*,
add a charset=xxx phrase to the Content-Type headers.
Or, suppress this action (by specifying charset=0)
CHARSET is used to override the
ADD_CHARSET parameter (in SREHTTP2.CFG).
|
---|
DEFAULTS |
A space delimited list of filenames (without path information).
These are used if the request selector is for a directory, and contains
no filename. Basically, this is a selector-specific replacement for the
SREhttp/2 DEFAULTS parameter.
Note: this is only useful when used with rules of the form:/foo/bar/*
or /foo/bar/
|
---|
EMPTH_PATH_OKAY |
Set to 1 to enable support for empty cgi-bin "paths", 0 to disable.
The default value of EMPTY_PATH_OKAY is a user-configurable parameter
that is declared in the SREH2INI.RXX file (in the \SRE2003\SREHTTP2 directory).
|
---|
ENABLE_CGI_PIECES |
ENABLE_CGI_PIECES=0: disable -- do not send in pieces
ENABLE_CGI_PIECES=1: enable -- do send in pieces
Enabling means that SREhttp/2 will try to read CGI-BIN output as it is written,
and then send these pieces. This is useful for long scripts that produce
intermittent output.
Notes: |
- This option is ignored if the ENABLE_CGI_PIECES parameter, in SREH2INI.RXX.
has been disabled.
- The ENABLE_CGI_PIECES parameter can be set to
disable, allow if explicitly enabled (with an ENABLE_CGI_PIECES
selector specific option), or do unless explicitly disabled.
|
|
---|
ETAG |
Explicitly specify an etag to include in the response.
Or, specify the method used to create an etag.
The syntax of ETAG follows that of the
ETAG option of SRE_COMMAND.
"an_etag" |
If you surround a string with quote (") characters, that string
is used as an explicit etag. Note that there should not be
any spaces in the an_etag |
AUTO, AUTO1, AUTO2 |
Automatically create an etag. AUTO is the default.
AUTO1 is the slowest, but most likely to be unique. |
SIMPLE |
Automatically create an etag. Uses a simple, perhaps not-quite-spec,
algorithim. SIMPLE is recommended when working with
resources that were PUT on your server (via
a PUT method request).
|
|
---|
EXPIRES |
Set a expiration time (using a Expires: response header).
The syntax of EXPIRES follows that of the
EXPIRES directive of SRE_COMMAND
|
---|
GET_PRIVS |
Force SREhttp/2 to try and obtain client privileges.
Using SET GET_PRIVS 1 has the same effect as setting the
ALWAYS_GET_PRIVS=2 SREHTTP2.CFG parameter.
Similarly, SET GET_PRIVS 0 is equivalent to
ALWAYS_GET_PRIVS=0
|
---|
IM |
IM is used to override the IM_DEFAULT option (in SRE2003.CFG).
IM 0 means "suppress Instance Manipulation" (such as delta encoding).
You can also use IM xxx to select an instance manipulation method, where
xxx must be one of the IM types specified in the
SRE2003.CFG IM_TYPES variable.
|
---|
LIMITtimeINACTIVE and LIMITtimeTOTAL |
LIMITtimeINACTIVE and LIMITtimeTOTAL are used to override the
SRE2003 time limit
(in seconds) variables -- but only for this request.
|
---|
MD5 |
1 to enable, or 0 to suppress, creation of an MD5: response header.
MD5 is used to override the DOMD5 parameter (in SREHTTP2.CFG).
|
---|
NOTIFY_MESSAGE |
NOTIFY_MESSAGE
is only used in conjunction with a NOTIFY redirection
rule. If used, it should be a simple message included in the
"notification" that is sent to the client (it may contain HTML tags).
|
---|
PRE_RESPONSE |
PRE_RESPONSE can take the following values:
PRE_RESPONSE is ignored if no pre-response procedures were specified in PRELOADS.CFG,
(see PRE_RESP.HTM for more details).
|
---|
POST_RESPONSE |
POST_RESPONSE can take the following values:
- 0 - do not call any post-response procedures
- string - a string that will be sent to (each of) the
post-response procedure(s) (must not contain a CRLF)
SET POST_RESPONSE is ignored if no post-response
procedures were specified in PRELOADS.CFG.
See POSTRESP.HTM, for more details.
|
---|
PUT_OVERWRITE |
Allow (1), or disallow (0), PUT method request to overwrite pre-existing files.
The (possibly host-specific) default value of PUT_OVERWRITE
is set in SREHTTP2.CFG.
If the PUT_OVERWRITE
parameter equals .... |
then the PUT_OVERWRITE selector specific action will ... |
0 |
the PUT_OVERWRITE option is ignored (overwrite will never be allowed). |
1 |
if PUT_OVERWRITE=1, overwrite is allowed. Otherwise, overwrite is not allowed
|
---|
2 |
if PUT_OVERWRITE=0, overwrite is not allowed. Otherwise, overwrite is allowed
|
---|
Notes: |
-
PUT_OVERWRITE can also be used by SREhttp/2 addons that upload files.
- PUT method requests are only allowed if a PUT
selector specific permission has been granted.
|
---|
|
---|
DYNPRIV_DURATION |
DYNPRIV_DURATION should be a number greater then 0.
It is the lifespan, in minutes, of dynamic privileges granted
in conjunction with this resource. Note that this overrides
the 15 minute default, but does not override an explicit duration.
Basically, this is used by the DYNP_LOG.CMD
addon. |
---|
3g) Controlling the maximum number of simultaneous users of a resource
You can use the MAX_USER.REX
EXEC procedure to control the maximum number of users who can simultaneously
be using a specific resource, or a broadly defined set (a family ) of resources.
Basically, if more then this number
of requests for this resource are currently active, the server will respond
with a Server busy, try again in a few minutes. This can be a useful
means of limiting access to CPU intensive scripts and addons.
Syntax:
4 arguments (seperated by a comma) can be included in the
Option: EXEC MAX_USER.REX line in your possibly host-specific
ATTRIBS.CFG file.
family | the set of resources to which the max_users applies
The family can extend across hosts, and across multiple realms --
in other words, families are
not intrinsically host specific, and are not intrinsically selector specific.
This implies that you can have multiple entries (each with it's own rule and
realm name) that use the same family.
|
---|
max_users | the maximum number of users |
---|
maxuser_failure_file | a failure file to use (if max_users is binding) |
---|
retryafter | Number of seconds to use in a Retry-After header.
If specified, a Retry-After response header is added to the
maxuser_failure_file response (http/1.1 clients can use Retry-After
response headers to automatically re-request the resource). |
---|
- family is case insensitive.
If it is not specified, then the action (the portion of the
selector before the ?) is used as the family.
- If max_users is not specified, then a value of 1 is used.
- if maxuser_failure_file is not specified (it should be relative to your
possibly host-specific CFG directory), a simple "server is busy"
response is returned.
- If retryafter is not specified, a Retry-After response header will NOT
be added.
- Note that family, whether it is explicitly defined or not, is not
host specific. That is, the set of users of a family of resources
(noting that a family can consist of just one resource)
is not sub-divided into what host the client sent a request to.
Examples (of entries in ATTRIBS.CFG)
Option: EXEC max_users.rex
Option: EXEC max_users.rex family1
Option: EXEC max_users.rex familyN, 6, FailFamn.htm , 30
Option: EXEC !max_u familyN ,4
Notes
- You can use the
Limit the number of simultaneous users of a resource
tool to set these limits.
- As the last example suggests ...
if you intend to use MAX_USER.REX frequently, you might want
to use the LOAD_EXEC option
(in PRELOADS.CFG) to "load" this
code into macrospace.
- As with the
LOGON_FAIL_FILE,
when the MAXUSER_FAIL_FILE is an HTML
document, server side includes are not attempted. However, a
few special substitutions will occur (when the MAXUSER_FAIL_FILE
is an HTML document):
<!--#URL--> | phrases are substituted with the request selector. |
<!--#SERVER--> | phrases are substituted with the servername. |
<!-- #MESSAGE --> | phrases are substituted with a short description
of the reason for failure |
<!-- #LINK --> | phrases are substituted with a URL which points
back to this resource |
- The retryafter argument only works with HTTP/1.1 browsers.
As an alternative,
that works with almost all currently used browsers, you can include the following
in the <HEAD> section of an HTML failure file:
<META HTTP-EQUIV="Refresh" CONTENT="6">
where the 6 is the number of seconds the browser will wait
before trying again --
of course, you can change this 6 to some other integer value.
-
To repeat: the family, whether it is explicitly defined or not,
is not intrinsically host or selector specific (though, you
can achieve this specificity by only using a particular family in one
host-specific realm).
Note that the max_users is selector specific. This means that even
though several resources may belong to a family, not all are equally
constrained (requests for some selectors will be honored even if the family
is being heavily used, while others will not).
3h) Modifying a realm's attributes on a client specific basis
The Client advanced option is used to allow the realm's attributes to be
client specific. More precisely, the realm's attributes can be functions of the
client's privileges.
For example, assume two sets of users; one with the NL client privilege
and the other with the AL client privileges. Then, you could modify
the redirect attribute as a function of these privileges. For example,
for /champs.htm, redirect the NL clients to /giants.html
and the AL clients to /angels.htm.
- Syntax:
- Client c_file
- where:
- c_file is a filename. If a relative file name, it will be relative
to the host-specific CFG subdirectory.
The c_file should have a stucture similar to ATTRIBS.CFG. However,
instead of using Realm and Rule to identify the records, you use
a Privs: line; where the Privs: is followed by a list of client-privileges.
-
In addition to a Privs: attribute, you can specify permissions,
redirect, and advanced options.
- You can not specify
rule, host, requires, failure, or option_file.
SREhttp/2 will compare the client's privileges
to the privileges contained in the privs attribute.
When a match occurs (using the same algorithim used with the
requires attribute), any
permissions, redirects, and advanced options associated with
this privs will be used.
Notes |
|
and some cautions |
The client advanced option should be used conservatively.
For example...
- several SREhttp/2 features (such as directory generation, and
the SENDFILE utility) can work with selector-specific attributes, but
do not recognize the client advanced option.
- although content-negotiated resources
are checked for selector-specific
attributes, the client option is not used
- You can not use the !REPEAT modifier on internal-redirections.
- You can not use the redirection shortcuts (such as Alias:
or Virtual:).
- If a client has several usernames for your site, but
entered a username that does not contain a privilege
listed in the c_file, there is no easy way to re-enter
a new username.
That is, a lack of matching client privilege does not
lead to a new authorization request. Instead, it means that the original
values of the selector-specific attributes will be used (no attempt will
be made to assign client-specific values).
|
Example of a
client file |
;this is used to modify attributes on a client specific basis
; it is used with the SPORTS_VU realm, which is defined with the rule /SPORTS/WATCH.HTM
privs: soccer
redirect: perm=http://www.mls.com
privs: baseball
redirect: perm=http://www.mlb.com
privs: football
redirect: perm=http://www.nfl.com
; amateur we handle here
privs: amateur
permissions: no_log no_ssi
;otherwise, use the attributes defined in the SPORTS_VU realm
|
4) A sample "advanced options file"
The following is a sample of an advanced options file. You might also want
to examine ADV_OPTS.CTL.
;------------- Begin Example ------------
; call the sample external procedure
exec exec_smp.rex This is an argument , with commas embedded.
;
; add a custom response header
header add X-Webmaster-Name: Timothy Platypus
;
; Suppress headers, footers, and server side "excludes"
ssi_no header footer
ssi_no select
; replace some strings in SSI html files
replace C.== $ Customiz
; suppress content-md5 header
set md5 0
;------------- End Example ------------
Last updated 24 September 2002