Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi Get resource info with HTTP (https://www.delphipraxis.net/178095-get-resource-info-http.html)

WojTec 17. Dez 2013 19:31

Get resource info with HTTP
 
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:

Delphi-Quellcode:
HTTP_QUERY_LAST_MODIFIED or HTTP_QUERY_FLAG_SYSTEMTIME
I also did it with Indy:

Delphi-Quellcode:
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?


Alle Zeitangaben in WEZ +1. Es ist jetzt 20:40 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz