Hard to believe that nobody noticed or reported this MAJOR bug in lNET so far, and no-one of the 200+ readers here seems to be able/interested to replicate this error in the past 2 weeks. Quite sad...
Anyway, today I digged deeper into this myself. The problem lies here:
\components\lnet\lib\lhttp.pp
2126 procedure TLHTTPClientSocket.ParseLine(pLineEnd: pchar);
2127 begin
2128 if FError <> ceNone then
2129 exit;
2130
2131 if FResponse^.Status = hsUnknown then
2132 begin
2133 ParseStatusLine(pLineEnd);
2134 exit;
2135 end;
2136
2137 inherited;
2138 end;
This causes the status only being read *ONCE* during runtime as FResponse^.Status is NEVER being reset. Pretty bad I though, so let's fix it:
2071 procedure TLHTTPClientSocket.SendRequest;
2072 var
2073 lMessage: TStringBuffer;
2074 lTemp: string[23];
2075 hasRangeStart, hasRangeEnd: boolean;
2076 begin
2077 lMessage := InitStringBuffer(504);
2078 FResponse^.Status := hsUnknown; // <== This works
2079 AppendString(lMessage, HTTPMethodStrings[FRequest^.Method]);
....
2123 WriteBlock;
2124 end;
I just inserted the above line in SendRequest(), resetting the status BEFORE every new request that is being send. No matter what kind of error occurs thereafter - the status will always be 'fresh' and up-to-date now, showing all HTTP status changes (after URI has changed, document disapperead, server error etc).
Note that the line numbers can be slightly different for you, depending on the version of your lNet sources.
@Almindor
You did a great job, but I would also recommend to make the TIMEOUT work on this component. I read your statement in another thread, but I disagree. What sense does it make if it's there, but doesn't work and can't be used? It DOES make sense for developers having a proper timeout for this control, it's a very basic feature that you'll find in every other blocking/networking control in commercial products (even in Visual Basic). In my application I had to implement my own timeout routine now where lNet is running in 3 different threads that I distroy after a given time. This is just awkward as it could be so simple...