title: Is there a way to set response timeout for Indy Tidhttp gets?
body: <p>I have built a simple website monitoring application using Indy TIdhttp component.  I want to detect when a designated page is not returned within a specified time frame (I am using 5000 milliseconds).  As a test I created a page on a web site which intentionally takes 15 seconds to respond.  But I can't get my procedure to "give up" after the 5 seconds.  I have tried <strong>ReadTimeout</strong>, a <a href="http://www.delphipages.com/forum/showthread.php?t=203619" rel="noreferrer">suggested solution</a> using a timer and the <strong>OnWorkBegin</strong> event (was never able to get <strong>OnWorkBegin</strong> to fire immediately after the get call).  </p>
  
  <p><strong>Note</strong> I am not worried about a connection timeout.  My concern here is a timeout for the server to return with a page.</p>
  
  <p>Here is some source code I have been using. It contains many of the elements I reference.</p>
  
  <pre><code>procedure TServLogic.WorkBegin(ASender: TObject; AWorkMode: TWorkMode; AWorkCountMax: Int64);
  begin
    GetTimer.Enabled := True;
  end;
  procedure TServLogic.WorkEnd(ASender: TObject; AWorkMode: TWorkMode);
  begin
    GetTimer.Enabled := False;
  end;
  
  procedure TServLogic.GetTimerTimer(Sender: TObject);
  begin
    idHttp.Disconnect(True);
  end;
  
  procedure TServLogic.CallHttp(mlink: String): String;
  begin
    result := '';
    GetTimer := TTimer.create(nil);
    GetTimer.OnTimer := GetTimerTimer;
    GetTimer.Interval := 5000;
    try
      IdHTTP := TIdHTTP.create(nil);
      idhttp.ReadTimeout := 5000;
      IdHttp.OnWorkBegin := WorkBegin;
      IdHttp.OnWorkEnd   := WorkEnd;
      try
        result  := idhttp.get(mLink);
      except
        on e:exception do begin
          AppendToLog('Server did not respond withing 5 seconds');
        end;
      end;
    finally
      GetTimer.Free;
      idhttp.free;
    end;
  end;
  </code></pre>