NSAPI: AuthTrans SAF for 6.0: distinguish sub-requests (e.g. SSI)?

I've got an AuthTrans access control SAF that provides access based on the client's apparent IP address. This SAF keeps a running count of the requests recognized. I would like this running count to only count distinct HTTP requests from the client, but it is also counting SSI requests.

That is, if the HTML page includes one SSI include tag:

-the client only makes one HTTP request to us (for "/index.htm")

-my AuthTrans runs twice, for /index.htm and for /includes/banner.htm

I call the request for /includes/banner.htm a "sub-request" because while Web Server handles it as a separate request, it is not explicitly made by the client.

I would like to add some C code to my NSAPI library so that my SAF could distinguish the sub-requests (/includes/banner.htm) from the "natural" requests (/index.htm), so that it would only count the "natural" hits (while still protecting sub-request content). Is there a good, clean way of doing that?

I know that I could (in our case) do something like

thisUri = pblock_findval("uri",rq->reqpb);

if ( (thisUri != NULL) && (strstr(thisUri,"/includes/") == thisUri) ) {

/* treat it as a sub-request */

}

I would much rather use a good NSAPI hook that didn't rely on my updating strings & carefully deploying my include files.

Thanks,

Peter

[1386 byte] By [PeterWatkinsa] at [2007-11-26 13:56:10]
# 1

It's not a formally supported part of NSAPI, but there is an undocumented way to check for internal requests such as SHTML includes:if (INTERNAL_REQUEST(rq)) {

/* This is not a client-initiated HTTP request */

}Even though it's not formally supported, the INTERNAL_REQUEST macro has been around for 10 years and isn't likely to go away. The INTERNAL_REQUEST macro is defined in nsapi.h.

Since you're using an AuthTrans SAF, you may also be concerned about restarted requests. For example, requesting / will typically cause the request to be restarted as a request for /index.html. You can use the RESTARTED_REQUEST macro to check for restarted requests:if (!INTERNAL_REQUEST(rq) && !RESTARTED_REQUEST(rq)) {

/* This is a client-initiated HTTP request */

}

elvinga at 2007-7-8 1:35:36 > top of Java-index,Web & Directory Servers,Web Servers...
# 2
Thanks, Chris, this is great! Special thanks for the "restarted" pointer -- this is just what I needed!-Peter
PeterWatkinsa at 2007-7-8 1:35:36 > top of Java-index,Web & Directory Servers,Web Servers...