Con la siguiente función, mejor o peor, pueden obtenerse las cabeceras HTTP de un determinado recurso en Internet partiendo de su URL.
Código Delphi
[-]
uses
WinInet;
function GetHttpHeaders(url: string): string;
var
agent: string;
flags: cardinal;
len, dummy: dword;
hInet, hUrl: hInternet;
headers: array [0..MAX_PATH] of char;
begin
dummy := 0;
len := sizeof(headers);
agent := 'Mozilla/3.0 (compatible;)';
flags := INTERNET_OPEN_TYPE_PRECONFIG;
hInet := InternetOpen(PChar(agent), flags, nil, nil, 0);
if (hInet <> nil) then begin
flags := INTERNET_FLAG_RELOAD;
hUrl := InternetOpenUrl(hInet, PChar(url), nil, 0, flags, 0);
if (hUrl <> nil) then begin
flags := HTTP_QUERY_RAW_HEADERS_CRLF or
HTTP_QUERY_FLAG_REQUEST_HEADERS;
if not HttpQueryInfo(hUrl, flags, @headers, len, dummy) then
begin
result := EmptyStr
end else begin
result := headers;
end;
InternetCloseHandle(hUrl);
end;
InternetCloseHandle(hInet);
end else begin
result := EmptyStr;
end;
end;