Molando
asked on
Indy: trying to write a proxy
What I am trying to do is create a http proxy. One that will check the url of the requested page, and only allow the connection if it is one held in a stringlist.
Delphi 7, latest version of Indy.
I place down an IDMappedPortTCP
onConnect I can athread.connection.readln( ) to pull out the requested address, but in doing so the page never gets downloaded.
How do I read from the thread without removing the data from the thread? I tried to link in an intercept or an IO handler, but in the object inspector the intercepts and iohandlers did not show.
What would be nice is the handfull of lines that let me see the requested url, and then stop the connection if it is not a defined one.
Delphi 7, latest version of Indy.
I place down an IDMappedPortTCP
onConnect I can athread.connection.readln(
How do I read from the thread without removing the data from the thread? I tried to link in an intercept or an IO handler, but in the object inspector the intercepts and iohandlers did not show.
What would be nice is the handfull of lines that let me see the requested url, and then stop the connection if it is not a defined one.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
points awardeed as no other comments on question. the comment solves half of my problem
Sorry that I ahd no further ideas. I do have another component that uses Francois Pettite's ICS components that will do what you need. The comp itself is OK and works and will do alot of neat stuff.
Check this link for the component but remember you need ICS.
http://www.delphipages.com/edit/count.cfm?ID=3489
This may help you a bit more. I plyed with it more extensively. The comp needs a bit of refinement and I never got around to it, but maybe this helps more and may redeem my lack of response!
Check this link for the component but remember you need ICS.
http://www.delphipages.com/edit/count.cfm?ID=3489
This may help you a bit more. I plyed with it more extensively. The comp needs a bit of refinement and I never got around to it, but maybe this helps more and may redeem my lack of response!
ASKER
using the onbeforecommand? event I can get the url requested. with athread.writeln (or buffer writes) I can send back the responce I want on a bad page. But how do I end the connection.
if I athread.free or athread.terminate after, then my responce does not reach the browser.
if I athread.connection.free then both my responce and the page I am trying to stop reaches the browser.
What I am aiming for is this.
we get the web page request.
if pos('WWW.CHEESE.COM',uppercase(DATA)) > 0 then begin
athread.connection.writeln
//somehow end the connection so that my responce reaches the browser, but www.cheese.com does not follow it.
end;