How i can make the Idhttp run in loop if return 404 page not found the problem is 'GOTO CheckAgain' leads into or out of TRY statement
label
CheckAgain;
begin
CheckAgain:
try
idhttp.Get(sURL+WebFile[I], S);
except
on E: EIdHTTPProtocolException do
if AnsiPos('404',E.Message) <> 0 then
begin
I := I+1;
goto CheckAgain;
end;
end;
end;
You have three options:
use a
try/exceptblock in a loop, catchingEIdHTTPProtocolExceptionexceptions and checking theirErrorCodeproperty for 404:if you are using an up-to-date version of Indy, you can enable the
hoNoProtocolErrorExceptionflag in theTIdHTTP.HTTPOptionsproperty, and then your loop can remove thetry/exceptand check theTIdHTTP.ResponseCodeproperty instead:use the overloaded version of the
TIdHTTP.Get()method that has anAIgnoreRepliesparameter, then you can tellGet()to not raise anEIdHTTPProtocolExceptionexception on a 404 response: