indy 9 and delphi 7 how do you idenifty the url for the redirect page so i can grab the text on the redirected web page

can anyone help me with some example code giving me the ability to grab text from the redirected page

for example:
 I use the following where s is defined as a string to grab a web page

   s := IdHTTP1.Get('');

if I go to an imagininary micorosft page that does not exist such as -it redirects to a page not found web page, I can catch the response code from the server using idhttp1. ResponseCode idenifying the web page has been reidrected.

what I want to do is grab the text on that redirected page and if possilbe grab the url. All I know is the code will be in the onrediect event for idhttp1.

thanks in advance

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Eddie ShipmanAll-around developerCommented:
The URL is in the dest parameter of the OnRedirect.
Eddie ShipmanAll-around developerCommented:
From the Indy help file:

TIdHTTPOnRedirectEvent = procedure (Sender: TObject; var dest: string; var NumRedirect: Integer; var Handled: boolean; var VMethod: TIdHTTPMethod) of object;


TIdHTTPOnRedirectEvent is a event type triggered when an HTTP client is notified of a redirection request from the HTTP server. TIdHTTPOnRedirectEvent is used in conjunction with an event handler to respond to the event.
Sender is the HTTP client that has received the redirection request.
Dest is the new location or URL for the resource. Dest is often used to update a GUI application with the current URL.

NumRedirects is a variable used to accumulate the number of redirection requests that the HTTP client has received.

Handled indicates that the event handler should respond to the redirection request. Set Handled to False if the application is unable to respond to the redirection

alchemy9Author Commented:
ok im still none the wiser, tried this an still no joy is it possible you could give me some sample code to show a redirect from the following page

 s := IdHTTP1.Get('');  //where s is a string

can you show me in code how the redirect will work and how to collect the redirected page into  a string or listbox

Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

Eddie ShipmanAll-around developerCommented:
Hate to say it but that page produces a 404, not found.
Microsoft's servers are configured to return the page you see.
I found no way to get the url's as the only response sent is the 404.
Eddie ShipmanAll-around developerCommented:
The OnRedirect never fires becuase it is not redirected but the server sends the error page
for the 404.
alchemy9Author Commented:
oops your right

but if you use you get a 301 error

anyway so my next question is this:

microsoft redirect to another page and IE downloads this reidrected page, so how can this be implemeted with indy. Is it possible to have a redirect even with a 404 error page not found????

All rather confusing.

Eddie ShipmanAll-around developerCommented:
Does the URL actually do a redirect?
I see that it doesn't go to a Microsoft page.

It really depends on how the server is configured. If it is configured to
show a different 404 page, then that is handled by the server and a
redirect is not sent.
alchemy9Author Commented:
OK but how does IE display this page?

the server must send a message to IE to display the 404 error page..
Eddie ShipmanAll-around developerCommented:
Yes, it sends it in the reponse stream. I don't know why Indy doesn't get it.
My suggestion at this pont would be to ask on the indy newsgroups.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.