Yep, thanks to my friend Gork, here the solution, create a independent http call and use it before to call the "heavy" http:
If you add your-routine inside cozipinc.dll, then you can avoid Exception
message, because , using value elseDoExcep<-100.
If you are inside mainprogram.exe with Debugger, then you cannot display errorException-> in this case you return wrong-error-number.
Perhaps, You scan too much the memory-of-EXE, with Pos('http:'),
i copied only first 15characters inside small-memory.(avoid memory-leaks)
Function cozipinc_urlacces(const curl:string;elseDoExcep:integer):integer;exports;
var Http: TFPHTTPClient;
Buf3:array[0..15] of char;
begin
Result := RTCAN;
fillchar(buf3,sizeof(Buf3),0);
if (length(curl)>=high(Buf3)) then copymemory(@Buf3[0],@curl[1],15) else
if (length(curl)>5) then copymemory(@Buf3[0],@curl[01],length(Curl));
Result:=RTINPUTTRUNCATED;
if (length(curl)>4094) then exit; //url is to large
if (Buf3[5]=#00) then exit;
Result := RTFAIL;
if (Pos('://',Buf3) < 5) then Exit;
Http := TFPHTTPClient.Create(nil);
try
Http.AllowRedirect := True;
Http.IOTimeout := 5000; // 5-second timeout
Http.ConnectTimeout := 5000;
Http.RequestHeaders.Clear;
try
Http.HTTPMethod('HEAD',curl, nil, [200, 204, 301, 302, 303, 307, 308]);
Result := RTNORM; // URL is accessible
except
ON E: Exception do
if (-100>elseDoExcep) then result:=elseDoExcep else
if (elseDoExcep>00)and(elseDoExcep<256) then
Writeln('URL check failed: ', E.Message);
end;
finally
Http.Free;
end;
end;