Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros temas > Trucos
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Los mejores trucos

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 12-02-2008
Avatar de dec
dec dec is offline
Moderador
 
Registrado: dic 2004
Ubicación: Alcobendas, Madrid, España
Posts: 13.107
Poder: 34
dec Tiene un aura espectaculardec Tiene un aura espectacular
Obtener las cabeceras HTTP desde una URL

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;
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 21:22:31.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi