首页 > 代码库 > What should I do about “302 Found” exceptions when downloading with Indy?

What should I do about “302 Found” exceptions when downloading with Indy?

Set the TIdHTTP.HandleRedirects property to True. It is False by default.

function FetchUrl(const url: string): string; 
var 
 idhttp : TIdHTTP; 
begin 
  idhttp := TIdHTTP.Create(nil); 
  try 
    idhttp.HandleRedirects := True;
    Result := idhttp.Get(url); 
  finally 
    idhttp.Free; 
  end; 
end;