AP SET WEB FILTERS

4D - Documentation   Français   English   German   4D_Pack, Command Theme List   4D_Pack, Command Alphabetical List   Back   Previous   Next

version 6.0.5


AP SET WEB FILTERS (filterIn; filterOut; charSet)

ParameterTypeDescription
filterInStringName of 4D method to call
filterOutStringName of 4D method to call
charSetLongintCharacter set to use with outgoing filter

Description

The AP SET WEB FILTERS command specifies the 4D methods called when data is incoming from or outgoing to an HTTP stream.

In a client/server configuration, this command must be called from a method executed on the server. These filters are applied for all processes.

To specify no incoming filter, pass an empty string as the filterIn parameter. To specify no outgoing filter, pass an empty string as the filterOut parameter.

The charSet parameter specifies the character set to use with the outgoing filter:

0: Data to filter are in the Web browser character set

1: Data to filter are in the Macintosh character set

Examples

1. Incoming filter: this method is called each time the Web browser sends a request. It is designed to collect information rather than to filter data.

      ` Incoming filter sample
      ` to know the address of the request sender
   C_BLOB($0;$1)
      ` $1 contains data coming from the browser
      ` $0 contains data to return to 4D
      ` We assume that the request is less than 32Kb
   $stream:=BLOB to text($1;Text without length)
   $pos:=Position("Host:";$stream)
   If ($pos>0)
      $host:=Substring($stream;$pos+5;Length($stream))
      $pos2:=Position(Char(13)+Char(10);$host)
         ` The host address is included between Host: and the carriage return.
      $hostaddress:=Substring($host;1;$pos2-1)
         ` ...
   End if
   $0:=$1   ` return data as they are

2. Outgoing filter: this is called each time 4D returns a reply to the browser (except the pictures). This function is designed to modify the HTTP stream header, or the HTML data of the page.

      ` Sample of outgoing filter
      ` which inserts a text in a page
   C_BLOB($0;$1)
      ` $1 contains data generated by 4D
      ` $0 contains data to send to Web browser
      ` We assume that the page is less than 32Kb
   $0:=$1   `copy the data 
   $stream:=BLOB to text($0;Text without length)
   $pos:=Pos("<BODY>";$stream)
   If ($pos>0)
      $text:="<BR><B>The text</B><BR><BR>"
      TEXT TO BLOB($text;$blob;Text without length)
      $pos:=$pos+5   `insert text after <BODY>
      INSERT IN BLOB($0;$pos;Length($text))
      $postxt:=0
      COPY BLOB($blob;$0;$postxt;$pos;Length($text))
   End if

4D - Documentation   Français   English   German   4D_Pack, Command Theme List   4D_Pack, Command Alphabetical List   Back   Previous   Next