SREhttp/2 Manual
Using SREhttp/2 Pre-Response Procedures
1) Introduction
SREhttp/2s pre-response procedure feature allows you (the savvy webmaster)
to have a last second shot at the contents to be sent to a client.
In other words, the pre-response is a hook into SREhttp/2, a hook that
occurs prior to sending the contents of a response to the client.
In general, this feature is best used when you need to make generic changes to
large sets of responses. For example, you may wish to translate text files into
alternative code pages (say, based on the user-agent). Or, you might want to
add an additional response header. Or, you might want to add a time and date
stamp to a subset of your text files. Or you might want to attempt special encoding (such
as GZIP content-encoding, or SREhttp/2's encryption)
to all document files.
Although quite powerful, this pre-response feature is a rather blunt,
and not particularly efficient, instrument. For example, any changes
due to a pre-response procedure will suppress SRE2003's request caching.
In many cases, you might be better off using one of the several other
request specific modifications possible in SREhttp/2, such as:
II) Usage
As with SRE2003 SRE2003's IM procedures, you
can specify several pre-response procedures, and then use one of these.
Although one of the pre-response procedures will be used by default, you can
also choose which one to use on a selector-specific
basis.
The following is done to specify pre-response procedures:
- Set PRE_RESPONSE parameter(s) in
PRELOADS.CFG (in the
SREHTTP2\CFG directory).
Each PRE_RESPONSE parameter should have the following structure:
PRE_RESPONSE= name file astring
where:
name | a short, case-insensitive, unique name that identifies
this pre-response procedure
- If you specify just one pre-response procedure, it will always be used
- If you specify several pre-response procedures, the default
procedure used will be determined by:
Note that instead of using the default you can choose a pre-response procedure on a
selector-specific basis. One of these choices is
to not call a pre-response procedure.
|
file | a fully qualified name of a file containing
an external REXX procedure; or a relative filename,
relative to the filter directory (eg; to the SREHTTP2 directory).
|
astring | an optional string that will be sent to the
pre-response procedure. It must not contain commas (commas will be
converted to spaces). Note that this string can be changed on a
selector specific basis
|
|
Examples:
|
PRE_RESPONSE= DEFAULT D:\SRE\PRE_RESP.RXX
PRE_RESPONSE= ENCRYPT procs\ENCRYPT.RXX SRE_A
PRE_RESPONSE= RSYNC D:\SRE\SRERsync.CMD
PRE_RESPONSE= DEFAULT 0
PRE_RESPONSE= 0
Notes:
- PRE_RESPONSE=0 means do not call a pre-response procedure.
If it is used, all other pre-response entries are ignored.
- PRE_RESPONSE=DEFAULT 0 means by default, do not call
a pre-response procedure.
|
- Create external REXX procedure(s).
Pre-response procedures will be called (by SREhttp/2) as:
stuff=SREH2_PRE_RESPONSE(contents,fileflag,mtype,message,req_string,seluse,privset,host_nickname,id_info)
where...
contents | the actual contents to be sent to the client, or a fully
qualified file name (whose contents is to be sent)
|
---|
fileflag
| |
---|
-
The stuff returned by your pre-response procedure should be:
nothing
| when the procedure does nothing (SREhttp/2 will then take care of
the response in its normal fashion)
|
0 status_code bytes_sent
| when the procedure responds to the client (using SRE_COMMAND).
Note that status_code bytes_sent is the value of the argument returned by the
call to SRE_COMMAND.
|
1 info '0d0a'x new_contents
| SREhttp/2 will return new_contents to the client
info can contain the following SRE_COMMAND('FILE ...') style directives:
- type type/subtype -- use type/subtype in the Content-Type header.
- EXPIRES nnn -- modify the Expiration content header.
- MD5 or NOMD5 -- enable/suppress generation of a Content-MD5 response header.
... or ...
|
1 '0d0a'x new_contents
| If info is not specified, the current value of the mimetype (and the Expiration
and Content-MD5) response headers are used.
|
III) Notes
Last updated 27 September 2002.