Autor Beitrag
sPeeD2k5
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 72



BeitragVerfasst: Di 02.09.08 11:07 
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
procedure TForm1.Button1Click(Sender: TObject);
var idhttp1 : TIdHTTP;
    host,path : String;
    code : integer;

begin
idhttp1 := TIdHTTP.Create;
host := Edit1.Text;
path := Edit2.Text;
//idhttp1.head(host+path);
//code := idhttp1.Responsecode;
try
idhttp1.ConnectTimeout:=1;
showmessage(inttostr(isHTTPSourceThere(host+path))) ;
except
 on EIdHTTPProtocolException do begin
  showmessage('geht nich');
  end;
  end;

end;

function TForm1.isHTTPSourceThere(const AURL: String): Integer;
var
  idhttp1:TIDhttp;
begin
  idhttp1 := Tidhttp.Create(nil);
  with IdHTTP1 do
  begin
    try
      Response.Clear;
      HEAD(AURL);
    except
    end;
    Result := IdHTTP1.ResponseCode;
  end;
  idhttp1.Free;
end;


Ich habe jetzt folgendes Problem.. Wenn er die Seite nicht findet hängt er sich erst mindestens 5 sekunden auf und gibt mir dann 404 zurück.. kann man das ganze beschleunigen? habs schon mit connecttimeout und readtimeout probiert aba funktioniert beides nich.. dauert trotzdem genauso lange

Moderiert von user profile iconGausi: Code- durch Delphi-Tags ersetzt
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Di 02.09.08 13:44 
Dann ist entweder der Server oder die Verbindung dorthin recht langsam.
Da kannst du vermutlich nicht viel machen.

Evtl hat es einen positiven Effekt, wenn du die idAntiFreeze Komponente auf dein Formular ziehst.

_________________
In the beginning was the word.
And the word was content-type: text/plain.