Solved

Indy: trying to write a proxy

Posted on 2004-09-01
4
1,086 Views
Last Modified: 2008-01-09
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.

0
Comment
Question by:Molando
  • 2
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
Johnjces earned 250 total points
ID: 11965384
Woops!

You might try installing the Indy HttpProxy component which can be found in the Indy folder called:

 IdHttpProxyServer.pas

Install it as you would any component and that may solve all of your problems. I played with it quite a bit and I think there is a demo somewhere in the Indy stuff as well.

It may help.

0
 
LVL 2

Author Comment

by:Molando
ID: 11970974
The http proxy solves half the problem.
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('my responce');
  //somehow end the connection so that my responce reaches the browser, but www.cheese.com does not follow it.
  end;
0
 
LVL 2

Author Comment

by:Molando
ID: 11983633
points awardeed as no other comments on question. the comment solves half of my problem
0
 
LVL 18

Expert Comment

by:Johnjces
ID: 11990300
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!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Communication Between RC4 Delphi <-> PHP 3 100
Create Database on Android via Delphi dbExpress 3 80
Magic Software info 18 125
RESTRequest Parameter 4 12
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now