ISAPI filter for compression using MFC4.2 WinInet classes
Sarveshwar Rao Surumpudi -- savy@infotech.stph.net
Saturday, January 04, 1997
Environment: VC++ 4.2b, NT 3.51
I am trying to write a ISAPI filter(using MFC 4.2 WinInet classes) for
an IIS server running on an NT-3.51 server. The functionality of the
filter is as follows:
1. Check if the URL requested for has a .xyz(my private format for a
binary file) extension.
2. As the data is being sent through the filter, the filter must do
appropriate buffering etc to ensure that only pre-defined sizes of data
are processed and sent to the client. For example, if the filter is
configured to process in chunks of 2K at a time and it gets an input of
(say) 1K in the first pass and another 1K in the second pass, the filter
should process the entire 2K together and then send the processed output
to the client.
3. The processing that I plan to do is compression. So I have a case
where the input to the filter has a size which is different from the
output that goes out from the filter.
I am trying to use the MFC 4.2 class CHttpFilter to implement the
filter.
Essentially I am overriding the OnSendRawData and OnURLMap memeber
functions of the class.
I experimented quite a bit with the memeber functions and the
information provided in the MSDN and VC++ books online . I felt that
it did not have enough information about the procedures
involved in controlling the HTTP request/response sequence from the
filter. The problems were in steps 2 and 3. I did see a note in quite a
few places in the documentation which said "the ISAPI filters are the
best place to implement compression and encryption of data".
Could some one give me a procedure/example to implement compression
using the CHttpFilter class.
savy
savy@infotech.stph.net
Mike Blaszczak -- mikeblas@nwlink.com
Saturday, January 04, 1997
At 14:20 1/4/97 +0530, Sarveshwar Rao Surumpudi wrote:
>Environment: VC++ 4.2b, NT 3.51
>I am trying to write a ISAPI filter(using MFC 4.2 WinInet classes)
There's no need to use the WinINet classes in the ISAPI Filter
application you describe. You should use only the ISAPI classes.
>I experimented quite a bit with the memeber functions and the
>information provided in the MSDN and VC++ books online . I felt that
>it did not have enough information about the procedures
>involved in controlling the HTTP request/response sequence from the
>filter.
Information about the HTTP protocol is best obtained from the Web
Consortium's website at http://www.w3.org. They own the standard
and very thoroughly document it. This documentation will help you
understand the transaction that's happening between the browser and
your server.
The documentation that ships with Internet Information Server is
the appropriate place to read about the way the server will make
calls to the filter. MFC doesn't document this because different servers
(and perhaps even different versions of the same filter) will process
the same call in different ways.
The documentation in the Interent Information Server package, further,
explains how to alter the reply data and size to your heart's content.
>Could some one give me a procedure/example to implement compression
>using the CHttpFilter class.
Try looking around at the ISAPI Developer's site at
http://rampages.onramp.net/~steveg/isapi.html.
.B ekiM
http://www.nwlink.com/~mikeblas/
I'm afraid I've become some sort of speed freak.
These words are my own. I do not speak on behalf of Microsoft.
George V. Reilly -- georger@microcrafts.com
Sunday, January 05, 1997
>Sarveshwar Rao Surumpudi[SMTP:savy@infotech.stph.net] writes:
>I am trying to write a ISAPI filter(using MFC 4.2 WinInet classes) for
>an IIS server running on an NT-3.51 server. The functionality of the
>filter is as follows:
>
>1. Check if the URL requested for has a .xyz(my private format for a
>binary file) extension.
If you're filtering on a particular file extension, you should
use script mapping. It's much easier to write an ISAPI extension
DLL than to write an ISAPI filter that mangles outgoing raw data.
Furthermore, an ISAPI filters that registers for raw data notification
has significant performance overheads.
You should also check out Stephen Genusa's ISAPI FAQ,
http://rampages.onramp.net/~steveg/isapifaq.html I suggest that
you also consider joining the ISAPI mailing list.
>
Here follows an unedited piece of mail that I sent to the
ISAPI list a few weeks ago about writing a filter. If you
still want to write a filter, it should be of some help.
>--
>/George V. Reilly
>MicroCrafts, Inc., 17371 NE 67th Ct #205, Redmond, WA 98052, USA.
>Tel: 206/250-0014 Fax: 250-0100 Web: http://www.microcrafts.com
>Vim 4 (vi clone) for NT & Windows 95: http://www.halcyon.com/gvr/
>pgp fingerprint: e2 b4 83 64 11 52 21 ea bf d8 51 c2 11 00 78 fc
>
>
>----------
>From: George V. Reilly
>Sent: Friday, December 20, 1996 4:48 PM
>To: ISAPI@LISTSERV.MSN.COM
>Subject: Re: Adding Data to Filter Client Return
>
>No, you're not being stupid. It's damned hard to get it right
>and it's not documented anywhere that I've seen. I had to
>pester a couple of IIS guys at Microsoft a few times until
>I figured it out. I'm still not sure that I understand all the
>issues, but what follows covers most of what you need to
>know.
>
>If you don't know until you've seen the end of the data how
>much data you're sending out, you need to
>(a) intercept OnPreprocHeaders and do a
> // Kill the "Connection: Keep-alive" header, so that browser
> // will terminate session properly
> pHeaders->SetHeader(pCtxt->m_pFC, "Connection:", "");
>(b) in OnSendRawData, you must delete the Content-Length line.
>
>If you do know how much data to send (e.g., you're
>prepending a fixed-size piece of text to the body), you
>don't need to do step (a) and you can _change_ the
>Content-Length line in (b) to the new length. Watch
>out for that line growing in size, e.g.,
> Content-Length: 924\r\n
>becoming
> Content-Length: 1073\r\n
>
>You must also take care to ensure that pvInData, cbInData, and
>cbInBuffer are updated appropriately, after you've processed
>each packet.
>
>Speaking of processing packets, there are _no_ guarantees
>about how many packets of data you'll receive for a page
>in your filter. If you're filtering HTML pages, you'll probably
>get all the headers in one packet, and then the body of the
>page split up into 8K chunks, but that's not safe to assume.
>If you're filtering the output of some ISAPI extension DLL,
>you might get it a line at a time or a byte at a time. If you're
>looking for particular strings, they might be split across two
>or more packets.
>
>Also, you might get the headers for a page, but not the
>body, if the user's browser decides that it's got a valid
>copy of the page in its cache.
>
>There's an automatic performance penalty for any
>ISAPI filter that intercepts RawData, because it has to
>copy the data from kernel memory to user memory. I've
>heard the figure of 50% overhead. I believe that this only
>applies to filters that mess with raw data, not ones that
>just do url remapping and the like.
>
>For all these reasons, the recommended route is to
>use script mapping instead. If you can restrict the things
>you want to filter to using a certain file extension, such
>as, say, .ASP, then life becomes much easier. If you
>have to filter all outgoing HTML, then you need to use
>an ISAPI filter, with all its attendant problems.
>
>Good luck.
>--
>/George V. Reilly
>MicroCrafts, Inc., 17371 NE 67th Ct #205, Redmond, WA 98052, USA.
>Tel: 206/250-0014 Fax: 250-0100 Web: http://www.microcrafts.com
>Vim 4 (vi clone) for NT & Windows 95: http://www.halcyon.com/gvr/
>pgp fingerprint: e2 b4 83 64 11 52 21 ea bf d8 51 c2 11 00 78 fc
>
>
>>----------
>>From: Byrne, Chris[SMTP:BYRC1@APTPCS.COM]
>>Sent: Thursday, December 19, 1996 10:41 AM
>>To: ISAPI@LISTSERV.MSN.COM
>>Subject: Adding Data to Filter Client Return
>>
>>OK I am probably being stupid but...
>>
>>Could some please explain how to add data to the HTML returned to a
>>client with a ISAPI Filter.
>>
>>Inside OnSendRawData():
>>I have tried in various combinations:
>>Remove the Connection and Content-Length headers from the data that
>>gets returned to the client but IE 3.0 still hangs.
>>Reset the pCtxt->cbInData
>>Reset the pCtxt->cbInBuffer
>>What am I Missing?.
>>
>>Please Take Pity and Respond,
>>Chris Byrne
| Вернуться в корень Архива
|