Einzelnen Beitrag anzeigen

DavidKlimas

Registriert seit: 24. Sep 2006
Ort: Arlon, Belgien
71 Beiträge
 
#3

AW: HTTP_QUERY_LOCATION gibt leeren String aus

  Alt 28. Mär 2013, 15:46
Volker,

jetzt klappt alles wie es soll. Hier ist die neue funktion. Ich musste auch der Errorcode 301 der anscheinend bei einem redirekt auftritt...

Delphi-Quellcode:
  hSession := InternetOpen('InetURL:/1.0', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
  if assigned(hsession) then
  begin
    repeat
    hfile := InternetOpenUrl (hsession, PChar (url), nil, 0, INTERNET_FLAG_NO_AUTO_REDIRECT, 0);
    {Get Validation}
    Buflen := 512;
    Dummy := 0;
    HttpQueryInfo(hfile, HTTP_QUERY_STATUS_CODE, @infoBuffer[0], Buflen, Dummy);
    result := (infoBuffer ='200') or (infoBuffer ='301') or (infoBuffer ='302');
    if result then
    begin
      {Get Link}
      Buflen := sizeof(infoBuffer2);
      Dummy := 0;
      HttpQueryInfo(hfile, HTTP_QUERY_LOCATION, @infoBuffer2[0], Buflen, Dummy);
      Str1 := infoBuffer2;
      if Str1 = url then Str1 := '';
      if Str1 <> 'then url := Str1;
    End;
    if assigned(hfile) then InternetCloseHandle(hfile);
    until (result = False) OR (Str1 = '');
    InternetCloseHandle(hsession);
  end;
  Mit Zitat antworten Zitat