?
Solved

Indy: trying to write a proxy

Posted on 2004-09-01
4
Medium Priority
?
1,112 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
Johnjces earned 500 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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…
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month9 days, 19 hours left to enroll

762 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