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:


1) Introduction

SREhttp/2's selector specific advanced-options provides a set of less-frequently needed, "advanced-options" to the ambitious webmaster. These advanced-options include:

2) Specifying advanced-options

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:

  • Using OPTION_FILE is recommended when you have many advanced-options, or when you want a set of Realms (as defined in ATTRIBS.CFG) to have the same set of advanced-options.
  • For further details on specifying advanced-options, see ATTRIBS.HTM.
  • There are NO global (default) advanced-options.
  • 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

    3) The advanced options

    There are several types of selector-specific advanced options:
    1. EXEC procedures -- execute an external REXX procedure.
    2. HEADER and RESPONSE directives -- specify a custom response header
    3. SSI_suppression directives -- suppress specific SSI actions.
    4. Set MIME type
    5. Replacement rules
    6. Set a few variables
    7. Controlling the maximum number of simultaneous users of a resource
    8. 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.

    3a) EXEC Procedures

    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:

    1. The SRE2003 "pre-transaction" procedure
    2. The SRE2003 "pre-request" procedure
    3. The fast-filter
    4. Invoking SREhttp/2...
    5. SREhttp/2 EXEC procedures
    6. SREhttp/2 "pre-response" procedure
    7. SRE2003 "IM" procedures
    8. 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:

    1. 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 ).

    2. Otherwise, EXEC procedures should return nothing (i.e.; return ' ').

    Notes:


    3b) HEADER and RESPONSE directives.

    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:


    3c) Server Side Include Suppression

    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:
      1. End with one of the SSI_EXTENSIONS
      2. Have a DO_SSI permission

    Examples:

       ssi_no cache
       ssi_no header    footer
       ssi_no select   #echo   #exec
    

    3d) Mime types

    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).


    3e) Replacement rules

    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:

  • Spaces will not be stripped from either old_string or new_string -- thus "invisible spaces" at the end of new_string will be retained.
  • Note the use of == as a seperator between old_string and new_string.
  • The order of appearance is the order of processing
  • Examples:
        REPLACE $(==<!-- $ customiz
        REPLACE )$== -->

    Notes:


    3f) Setting variables

    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)
    ETAGspecify 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:
    • 0 - do not call a pre-response procedure
    • aname string - aname case-insensitively identifies which pre-response procedure to use. string is an optional string to be sent to this pre-response procedure.

      Note that aname must match one of the identifying names used in PRELOADS.CFG (where pre-response procedures are specified). Otherwise, an error will occur.

    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).

    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


    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
  • If you specify many of these client attribute files, we recommend placing them in a subdirectory (say, a CCFG subdirectory of your possibly host-specific CFG directory).
  • If no authorization request header is available, SREhttp/2 will send a simple authorization response. Technically speaking, use of a client advanced option forces ALWAYS_GET_PRIVS=1
  • In a sense, the client advanced option is similar to content-negotiation -- it provides a way for information provided by the client to influence what resource variant is returned. However, client can do more than that -- it can set permissions, and change the other advanced options.
  • For all requests belonging to realms that contain a client attribute, the SRE2003 request cache is disabled.
  • 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