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

Posted on 2003-11-19
Last Modified: 2012-05-07
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

Question by:alchemy9
  • 6
  • 3
LVL 26

Expert Comment

ID: 9787426
The URL is in the dest parameter of the OnRedirect.
LVL 26

Expert Comment

ID: 9787441
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


Author Comment

ID: 9790107
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

LVL 26

Expert Comment

ID: 9790689
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.
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

LVL 26

Expert Comment

ID: 9790694
The OnRedirect never fires becuase it is not redirected but the server sends the error page
for the 404.

Author Comment

ID: 9791521
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.

LVL 26

Expert Comment

ID: 9799587
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.

Author Comment

ID: 9800505
OK but how does IE display this page?

the server must send a message to IE to display the 404 error page..
LVL 26

Accepted Solution

EddieShipman earned 250 total points
ID: 9800595
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.

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

746 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

9 Experts available now in Live!

Get 1:1 Help Now