Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Mar : TIdHttp and redirection
| Subject: | TIdHttp and redirection |
| Posted by: | "Shiva" (shi..@gonzo.com) |
| Date: | Mon, 20 Mar 2006 20:21:58 |
Hi,
I'd like to get the redirected address after a redirection (302 HTTP
response message). Unfortunately,
this piece of code does not work:
function TDownloadThread.HttpGetHtml(var aAddress: string; var
aAddressOnPage: string; var aHTML: string; aMethod: string; var
aRedirectedAddress: string): boolean;
var
HTTP : TIdHttp;
begin
aRedirectedAddress := aAddress;
HTTP := TIdHttp.Create(nil);
try
HTTP.HandleRedirects := true;
aHTML := HTTP.Get(aAddress);
if HTTP.Response.ResponseCode = 302 then
aRedirectedAddress := HTTP.Response.Location
<etc..>
So aRedirectedAddress should be filled with the redirected address. What's
wrong with this piece of code?
Thanks in advance.