Use the HEAD method, remembering that if the answer is not 200 (ok), the routine will fall into an exception and it should be handled.
Follow the example in the question:
procedure TForm1.Button1Click(Sender: TObject);
var
http : TIdHttp;
url : string;
codigo : integer;
begin
url := 'http://www.xxx.com.br/teste.php?Teste';
http := TIdHTTP.Create(nil);
try
try
http.Head(url);
codigo := http.ResponseCode;
except
on E: EIdHTTPProtocolException do
codigo := http.ResponseCode;
end;
ShowMessage(IntToStr(codigo));
finally
http.Free();
end;
end;
Remembering that to make the word OK appear, just use a case in the code variable. To do this, follow the list of HTTP response codes