ISAPI filter to post-process requests
am 29.01.2008 21:24:56 von AptanaPaul
We are trying to write an ISAPI filter to do post processing of requests.
Here are the requirements of our filter:
1. It needs to hold (blocking) all information until it receives the entire
request (headers, server variables, document body, post data), then it will
process the request and generate headers and body to be sent to the client.
(It just cannot act on pieces of information and move on.)
2. We would like to get postdata regardless if the actual handler requests
it or not. We would like to get it for both http and https requests.
3. (partly in #1) We would like to modify the headers "after" we have
received the entire document.
Here is a little experiment I did (I was told this is not the right
approache, but do not have a better alternative yet):
Register my filter at the global level (so I can get the post data --
but seems still cannot get it if the handler does not ask for it).
Subscribe variouse kinds of events, so I can collect all headers, and
server variables, document body, (and post data).
When we receive the SF_NOTIFY_END_OF_REQUEST event, (this is the
starting point of our own process of the page/request. I can use the
content_length to figure out when I have got the entire doc in the
SF_NOTIFY_SEND_RAW_DATA event, but I do not think that's reliable), we send
all the information we collect for this request (headers, server variables,
document, postdata) to our internal process. The internal process (which
must receive all such information before it returns anything) will process
the request and return a new document with new headers and/or modified
headers. We will update the headers with the ones sent from our process to
the existing headers (add or modify), and send them with the new document to
the client.
I used HTTP_FILTER_CONTEXT* pFC's AddResponseHeaders, but did not see
them in the response received from the browser.
We also thought about writing a Handler that handles all relevent
extensions (eg .asp, .aspx, etc), and in it, we delegate the actual handling
to the proper handler, and intercept the result and modify them. But this
seems not good either.
So given the problem we would like to resolve, how can we make our ISAPI
work?
Thanks,
RE: ISAPI filter to post-process requests
am 30.01.2008 11:23:16 von wjzhang
Hi Paul,
First of all, I wonder if you are writing the ISAPI application to run on
Windows 2003 server/IIS 6.0. If so, you'd better to implement the solution
with a new supported wildcard ISAPI extenstion on IIS6 instead of an ISAPI
filter. This is because it isn't recommended to cover any of the following
scenarios in a filter:
1. Accessing entity request body,
2. Potential long-running operation and
3. Using SF_NOTIFY_SEND_RAW_DATA on IIS6
By using a wildcard mapping, your ISAPI extension(execute before any common
extension) can easily interact with all incoming requests of a site/vdir
and modify the responses' header and body. Please take a look at the
following article:
Benefits of Using Wildcard Application Mappings Instead of ISAPI Filters
http://www.microsoft.com/technet/prodtechnol/WindowsServer20 03/Library/IIS/a
d520e25-877c-4764-bfe5-a9d5a9a5d3bb.mspx?mfr=true
The following references on MSDN should be useful and the corresponding
sample codes can be found in Windows 2003 SP1's Platform SDK.
Intercepting All Incoming IIS Requests
http://msdn2.microsoft.com/en-us/library/ms525696(VS.85).asp x
Remapping a URL Using Wildcard Application Maps
http://msdn2.microsoft.com/en-us/library/ms525529(VS.85).asp x
Implementing Custom Authentication Using Wildcard Application Maps
http://msdn2.microsoft.com/en-us/library/ms525161(VS.85).asp x
Sending Response Headers from ISAPI Extensions
http://msdn2.microsoft.com/en-us/library/ms524895(VS.85).asp x
I hope information above helps. Please update on any further questions or
concerns.
Have a great day.
Sincerely,
WenJun Zhang
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscriptions/managednewsgroups/de fault.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at:
http://msdn.microsoft.com/subscriptions/support/default.aspx .
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
RE: ISAPI filter to post-process requests
am 01.02.2008 14:16:21 von wjzhang
Hi Paul,
Do you have any further question or concern of this issue?
Have a nice weekend.
Sincerely,
WenJun Zhang
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscriptions/managednewsgroups/de fault.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at:
http://msdn.microsoft.com/subscriptions/support/default.aspx .
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.