I need to know remote file length and time, so I wrote with WinInet:
Delphi-Quellcode:
var
hInet, hURL: HINTERNET;
BufferLength: Cardinal;
Reserved: Cardinal;
begin
Result := 0;
Reserved := 0;
hInet := InternetOpen(PChar(AUserAgent), INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
if hInet <> nil then
try
hURL := InternetOpenUrl(hInet, PChar(AURL), nil, 0, 0, 0);
if hURL <> nil then
try
BufferLength := SizeOf(Result);
HttpQueryInfo(hURL, HTTP_QUERY_CONTENT_LENGTH or HTTP_QUERY_FLAG_NUMBER, @Result, BufferLength, Reserved);
finally
InternetCloseHandle(hURL);
end;
finally
InternetCloseHandle(hInet)
end;
end;
and in another function:
HTTP_QUERY_LAST_MODIFIED or HTTP_QUERY_FLAG_SYSTEMTIME
I also did it with
Indy:
TIdHTTP.Head();
API version (one function call in the same time, not both) is noticeably slower than
VCL.
1. How to do it faster in
API?
2. Is possible get more data by one HttpQueryInfo() or have to use one call for one HTTP response field?