04 Mar 1999. Orginally submitted by Timur Kazimrov. 
Updated 28 Dec 2002 by Daniel Hellerstein

Two pre-response procedures for SREhttp/2

CVT_PAGE: A Code page conversion pre-response procedure for SREhttp/2

and

PACKBACK: strip CRLFs, unused spaces, and comments from outgoing HTML documents, 
         for selected clients. 


28 Dec 02 WARNING::::: CVT_PAGE does not seem to work on our test machine.
                       We are looking into it .....


Initialization:
          
     You can use the SREhttp/2 configurator (the "select pre-response procedure"
     option) to enable either of these on a selector-specific basis.  

    Alternatively, you can ...
        
     i) To use cvt_page or packback by default, you can modify PRELOADS.CFG: 

           by default there should be the lines:
                pre_response=cvt_page procs\cvt_page.rex
                pre_response=packback procs\packback.rex GZIP

           to enable CVT_PAGE for all requests, change this to
               pre_response=default procs\cvt_page
           to enable packback for all requests, change this to
               pre_response=default procs\packback [GZIP]
               (the GZIP is optional)
           or, 
             a) make the 
                  pre_response=cvtpage procs\zz   (zz is cvt_page.rex or packback.rex)
                the first of the "pre_response= ..." lines 
             b) comment out the line 
                  pre_response=default 0

    ii) to "do by hand" the enabling on a selector-specific basis ....
      you can create a selector specific entry, in the possibly 
      host-specific ATTRIBS.CFG, that contains a line like:
         SET PRE_RESPONSE PACKBACK [GZIP]  (the GZIP is optional) 
      or
         SET PRE_RESPONSE CVT_PAGE


Notes:
  *  You can only use ONE pre-response procedure per request.
     If you want to use both of these (or these in combination with other
     pre-response procedures) you'll have to create your own "pre-respnse" 
     manager that calls each pre-response procedures in the
     proper sequence.

  *   RXCPAGE.DLL uses RXCPAGE.DLL, which is installed to the DLL subdirectory
      of SRE2003.

                   ---------------------------------

Notes on CVT_PAGE:


CVT_PAGE output from one Cyrillic codepage to another using information about
user browser and some default settings

For TEXT/PLAIN documents there is no guessing of document's codepage
and BASE_SET codepage is used.
  
For TEXT/HTML documents the <META HTTP-EQUIV> keyword is looked for and
if found the information from CHARSET field is used and this tag is deleted.
In other cases the BASE_SET codepage is used.

Before using this procedure check the rules for determining codepage
or browsers - maybe you'll find that some are unapplicable!!!


Some user-configurable parameters (in CVT_PAGE.REX)


ADD_EXTERNAL_DEFS 
   determines where to load additional information about browsers and 
   corresponding preferred codepages.
   It must be fully qualified file name or 0 if you do not want to
   load additional information.

   For example, 
        ADD_EXTERNAL_DEFS='D:\GOSERVE\DATA\CP_BROWS.DAT' 
   means oad information from file D:\GOSERVE\DATA\CP_BROWS.DAT

   WARNING!!! Definition from database overrides the default (hardcoded) values
              These hard coded values are set in CVT_PAGE.REX -- you can
              change them, just be careful and read the comments.

   Note: an example of an add_externals_def file is CVT_PAGE.CFG (in 
         the SREHTTP2\CFG directory

                   ---------------------------------

Notes on PACKBACK:

** The GZIP option
   If you include GZIP when enabling the PACKBACK pre-response procedure,
   then PACKBACK will also try to GZIP contents.
   This GZIP is done either:
     i) after removing unnecessary spaces, etc. from HTML files
    ii) if not an HTML file -- to the contents as is
   Of course, this is only done if the client understands GZIP as a 
   content-encoding.

   Basically, use of the GZIP option means "always do GZIP, even if you don't
   do anything else"


** The user-changeable parameters:
   ... pay special attention to  bytes_second and maxdocsize

ClientsToPack

    a) set ClientsToPack.0= # of entries
    b) set ClientsToPack.n= a numeric IP address (n=1,..,ClientsToPack.0).
       You can use * as wildcards.
       For example:   if the client's IP address is 199.122.33.1, then
       the following will match:
                ClientsToPack.3='199.122.33.1'
                ClientsToPack.3='199.122.*'
                ClientsToPack.3='199.12*'

    Example:
        CLIENTSTOPACK.0=1
        CLIENTSTOPACK.1='199.*' 


MaxDocSize:
   If the source document is larger than MAXDOCSIZE the compression
   won't be performed. This parameter should be tuned. Size is
   in bytes.
   Note: large files can take a minute or longer to process, which can cause
         an "inactive-timeout". To avoid this,  increase the options-limit-
         end_client_after_inactive GoServe parameter

  Example:
     MAXDOCSIZE=1500000  /* All documents larger that 1,500,000 bytes won't be compressed */


MinDocSize
   If the source document is smaller than MINDOCSIZE the compressing
   won't be performed. This parameter should be tuned. Size is
   in bytes. 

   Example:
       MINDOCSIZE=2000  /* All documents smaller that 2000 bytes won't be compressed */


Bytes_second

   This is used to set the LimitTimeInactive SRE2003 setting, so as
   to avoid timeout problems due to slow processing times.

   The value should be the expected processing power of this 
   procedure on your server's hardware, in  bytes per second.  

   Hence, if bytes_second=5000 and the size of a file is 150,000,
   then LimitTimemInactive will be set to 30 seconds (for this
   request).

   To disable this check, set bytes_second=0

   Example: 
       bytes_second=5000



