Delphi: Why does IdHTTP.ConnectTimeout make requests slower?
- by K.Sandell
I discovered that when setting the ConnectTimeoout property for a TIdHTTP component, it makes the requests (GET and POST) become about 120ms slower?
Why is this, and can I avoid/bypass this somehow?
Env: D2010 with shipped Indy components, all updates installed for D2010. OS is WinXP (32bit) SP3 with most patches...
My timing routine is:
Procedure DoGet;
Var
Freq,T1,T2 : Int64;
Cli : TIdHTTP;
S : String;
begin
QueryPerformanceFrequency(Freq);
Try
QueryPerformanceCounter(T1);
Cli := TIdHTTP.Create( NIL );
Cli.ConnectTimeout := 1000; // without this we get < 15ms!!
S := Cli.Get('http://127.0.0.1/empty_page.php');
Finally
FreeAndNil(Cli);
QueryPerformanceCounter(T2);
End;
Memo1.Lines.Add('Time = '+FormatFloat('0.000',(T2-T1)/Freq) );
End;
With the ConnectTimeout set in code I get avg. times of 130-140ms, without it's about 5-15ms ...