I was hoping it would be something along these lines. Is there a technical way to determine whether the request is an Active4D page (how does active 4d do this) or do you just make a determination based on the url's you know you are serving?
Active4D can be configured to serve files with certain suffixes. This is done through the executable extensions in the Active4D.ini file. However, since the 4D web server gets the request before Active4D you'll need to write code that will instruct it to hand certain files to Active4D.
I do it based on URL's. In our case it's as simple as seeing if the request contains a pattern. Since most Active4D pages end with .a4d you can look for that. We actually look for files with Netlink style URLs, but either criteria should be suitable.
With ITK you have to examine the incoming request. The requested URL will be in the first line of that request, which can be easily parsed out using regular expressions or native 4D string handling code. From there you can see if your match criteria is in the first line of the header. Here's part of the code to do it with ITK. Note that this uses the QFree plugin for regular expressions, and BASh for its DSS module.
$err:=ITK_TCPRcv ($streamRef;$headerTxt;32000;0;0;<>CRLF+<>CRLF;2*60) `Grab the header...
$err:=ITK_TCPUnRcv ($streamRef;$headerTxt;1) `... and put it back!
`examine header for info that might indicate a request for an Active4D file type.
C_TEXT($regex;$requestStr)
C_POINTER($matches_aPtr)
$matches_aPtr:=DSS_Get_Variable_by_Type (Text array )
$regex:="(?i)[^ ]+ ([^ ]+) .+\x0D\x0A"
$matchOK:=PREG_Match ($regex;$headerTxt;$matches_aPtr)
If ($matchOK)
If (Size of array($matches_aPtr->)>=1)
$requestStr:=$matches_aPtr->{1}
End if
End ifDSS_Return_Variable ($matches_aPtr)
`code to determine whether this was an A4D or other request would go below. ...
The mechanics for the 4D web server will probably be different, but the general idea is the same.
-- Brad
