Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Mar : Re: Conditional TidHttp.GET()
| Subject: | Re: Conditional TidHttp.GET() |
| Posted by: | "Joe Aley" (joealey20..@yahoo.com) |
| Date: | Mon, 5 Mar 2007 23:10:37 |
Remy Lebeau (TeamB) wrote:
> Set the TIdHTTP.Request.LastModified property before calling Get().
>
> Note - if you are using Indy 9 or earlier, Get() will throw an
> exception if it receives a 304 reply, though. You will have to wrap
> the call in a try..except block, and then check the
> TIdHTTP.Response.ResponseCode property in the except section.
>
> If you are using Ind 10, on the other hand, then you can pass 304 to
> Get()'s AIgnoreReplies parameter, and the exception will not be
> thrown.
>
>
> Gambit
>
>
So here goes the sample for indy 9...
//--------------------------------------------------
procedure TForm1.Button1Click(Sender: TObject);
begin
IdHTTP1.Request.LastModified := Now();
try
IdHTTP1.Get('http://www.mydomain.com/myimage.jpg');
except on E : Exception do begin
if(IdHTTP1.ResponseCode = 304) then begin
ShowMessage('The page was not modified!');
end;
end;
end;
end;
//--------------------------------------------------
end.
Thanks again Gambit.