How to check URL with IdHTTP?

前端 未结 2 1069
心在旅途
心在旅途 2020-12-01 05:08

How can I check for the target URL for specific response code like 200 OK without Indy throwing all sorts of exceptions out. ConnectionTimeout,ConnectionClosedGracefully, et

2条回答
  •  孤独总比滥情好
    2020-12-01 05:19

    A plain try/except should do the trick:

    try
      IdHttp1.Get(...);
      Result:=IdHttp1.ResponseCode=200;
    except on EIdException do
      Result:=false;
    end;
    

提交回复
热议问题