[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Indy: trying to write a proxy

Posted on 2004-09-01
4
Medium Priority
?
1,117 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

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…
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 tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

656 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