mtieland
asked on
ISAPI Filter? HOW?
Hello,
I am looking for a way to write a ISAPI filter in Delphi. Can anyone point me into a direction where to find examples and/or documentation on this matter.
Thanx.
I am looking for a way to write a ISAPI filter in Delphi. Can anyone point me into a direction where to find examples and/or documentation on this matter.
Thanx.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
he has a article here but im having diffuculty getting the page to load so dont kow if its still there or not:
www.xapxone.com/html/dl304.htm
www.xapxone.com/html/dl304.htm
ASKER
Exactly what I was looking for,
And a funny way of writing too...
Thanx a lot.
(Sorry for the others I can give points only once so the
first good answer gets the points)
And a funny way of writing too...
Thanx a lot.
(Sorry for the others I can give points only once so the
first good answer gets the points)
ASKER
Something I found out about redirecting on the URL_MAP event:
res := 'Location: ' + 'http://www.mylink.com' + #13+#10+#13+#10;
TServerSupportFunc (pfc.ServerSupportFunc) (pfc, SF_REQ_SEND_RESPONSE_HEADE R,pChar('3 02 Redirect'), Cardinal(PChar(res)) , 0);
The second line shows the way you should do the actual redirect!
Martijn
res := 'Location: ' + 'http://www.mylink.com' + #13+#10+#13+#10;
TServerSupportFunc (pfc.ServerSupportFunc) (pfc, SF_REQ_SEND_RESPONSE_HEADE
The second line shows the way you should do the actual redirect!
Martijn
it sends all incoming requests from an MSIE client
to a virtual directory called /NoIE/
library browser;
uses
Windows,
SysUtils,
ISAPI2;
const
FilterDescription = 'An ISAPI filter that will not let Internet
Explorer into the site.';
function GetFilterVersion(var pVer : THTTP_FILTER_VERSION) : BOOL;
export; stdcall;
begin
Result := True;
try
pVer.dwFlags := (SF_NOTIFY_SECURE_PORT
or SF_NOTIFY_NONSECURE_PORT
or SF_NOTIFY_PREPROC_HEADERS //This is what
we are interested in
or SF_NOTIFY_ORDER_LOW
);
pVer.dwFilterVersion := HTTP_FILTER_REVISION;
StrPCopy(pVer.lpszFilterDe
except
Result := False;
end;
end;
function HttpFilterProc( var pfc: THTTP_FILTER_CONTEXT;
NotificationType : DWORD;
pvNotification : Pointer): DWORD;
export; stdcall;
var
PreprocHeaders : THTTP_FILTER_PREPROC_HEADE
Buffer: array[0..1024] of Char;
BufferSize: DWORD;
AgentStr, URL: string;
aPos: Integer;
const
sUserAgent = 'USER-AGENT:';
sURL = 'url';
NewURL = '/NoIE/'; //Note -- the URL _must_ have a '/' on the end
by the end of this function
function NoIE: DWORD;
begin
PreprocHeaders := THTTP_FILTER_PREPROC_HEADE
//cast to proper record type
BufferSize := SizeOf(Buffer);
PreprocHeaders.GetHeader(p
//Grab the URL. It will be everything after the domain
SetString(AgentStr, Buffer, BufferSize);
if Pos('MSIE', AgentStr) > 0 then //if we are dealing with MSIE
begin
BufferSize := SizeOf(Buffer); //Reset Buffer for new use
PreprocHeaders.GetHeader(p
SetString(URL, Buffer, BufferSize);
//Replace whatever the URL is with the /NoIE/ URL
aPos := Pos('/', URL);
Delete(URL, aPos, Length(URL) - aPos + 1);
URL := Concat(URL, NewURL);
//This sends out the new header and sents the request on its way
PreprocHeaders.SetHeader(p
end;
Result := SF_STATUS_REQ_NEXT_NOTIFIC
ready to go on
end;
begin
case NotificationType of
SF_NOTIFY_PREPROC_HEADERS : Result := NoIE;
else
Result := SF_STATUS_REQ_NEXT_NOTIFIC
end;
end;
exports
HttpFilterProc,
GetFilterVersion;
end.