Solved

Indy: trying to write a proxy

Posted on 2004-09-01
4
1,091 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Run video youtube webbrowse 10 63
Magic Software info 18 132
Delphi: making a BW image transparent 10 42
DBCtrlGrid, Delphi, Scroll 8 15
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

825 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