Autor Beitrag
Bennle
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 101

WinXP
Delphi 2007 Pro, C# (VS 2005)
BeitragVerfasst: Mo 27.11.06 13:46 
Hallo,
Ich möchte mittels Indy feststellen, ob der Fehler 404 auftritt! Wie kann ich das herausfinden?

Kann mir jemand einen kleinen Codeschnippsel geben?

MfG
Bennle
JoelH
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 806
Erhaltene Danke: 17

Win10
Delphi Alexandria 11.2 Patch 1
BeitragVerfasst: Mo 05.03.07 12:47 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure TForm1.Button1Click(Sender: TObject);
begin
  memo1.Clear;
 try
   memo1.Text :=  IdHTTP1.Get('http://www.joelh.de/test.html');
 except
   memo1.Text := IdHTTP1.ResponseText;
   if POS('404',memo1.Text) > 0 then
     showmessage('404 - File not found on Server');
 end;
end;


Dies ist mit der IdHTTP-Komponente gelöst. Im Exceptfall kommt dieser text zurück:
Zitat:

HTTP/1.1 404 Not Found

Diesen kannst du mit dem POS nach 404 durchsuchen und schon hast du die Sache gelöst.

_________________
mfg. Joel