I am using TNMHTTP in Delphi to retrieve code from a web page. The code is relatively simple:
NMHTTP1 := TNMHTTP.Create(Self);
NMHTTP1.InputFileMode := FALSE;
NMHTTP1.OutputFileMode := FALSE;
NMHTTP1.ReportLevel := Status_Basic;
NMHTTP1.TimeOut := 3000;
URL := 'http://www....';
NMHTTP1.Get(URL);
S := NMHTTP1.Body;
I deal with exceptions in the try / except block, but this is not a problem.
The problem is that when the NMHTTP1.Get method is executed, when the URL is redirected, this method does not return and the program freezes. This is despite the fact that I turned on the timeout of 3000 seconds.
So, I see three possible ways to solve this problem (in order to easily change my program):
Do whatever it takes to get the NMHTTP1.Get response.
Do some checking before the NMHTTP1.Get statement to see if the URL is redirected and get the URL to which it redirects.
- Delphi. , Delphi 4 Indy. Delphi 2009, -, (, INDY), # 1 # 2 .
-, . .