Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi Problem mit IdHTTP Exception 'HTTP/1.1 302 Moved Temporarily (https://www.delphipraxis.net/136893-problem-mit-idhttp-exception-http-1-1-302-moved-temporarily.html)

emsländer 9. Jul 2009 17:21


Problem mit IdHTTP Exception 'HTTP/1.1 302 Moved Temporarily
 
Moin,

hab da so ein mittelprächtiges Problem. Dieses kleine Ding wird aufgerufen, um eine Webseite im gewissen Turnus zu ziehen. Alle x-Mal (keine Regelmäßigkeit) kommt es zu o.g. Fehlermeldung.

Hat da jemand eine Idee?

Delphi-Quellcode:
unit online;

interface

  function weblesen(sURL : string) : ansistring;

implementation

uses main,classes, sysutils, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
             IdHTTP, IdAntiFreezeBase, IdAntiFreeze;

function weblesen(sURL : string) : ansistring;
  var sstream : Tstringstream;
       httpcon : TIdHTTP;
       antifreeze : TIdAntiFreeze;
begin
  result := '';
  sstream := tstringstream.Create('');
  try
    antifreeze := TIdAntiFreeze.Create(nil);
    httpcon := TIdHTTP.create;
    antifreeze.Active := true;
    HttpCon.Get(sURL,sstream);
    result := utf8towidestring(sstream.DataString);
  except
    httpcon.Disconnect;
  end;
  antifreeze.Active := false;
  freeandnil(httpcon);
  freeandnil(antifreeze);
  freeandnil(sstream);
end;
end.
Gruss

EL

Klaus01 9. Jul 2009 17:28

Re: Problem mit IdHTTP Exception 'HTTP/1.1 302 Moved Tempora
 
Guten Abend,

gibt es bei den Indys nicht eine Option HandleRedirect o.ä.

Grüße
Klaus

shmia 9. Jul 2009 17:29

Re: Problem mit IdHTTP Exception 'HTTP/1.1 302 Moved Tempora
 
Property HandleRedirects auf True setzen, dann folgt die Komponente der neuen URL.
Delphi-Quellcode:
httpcon.HandleRedirects := true;
Hier noch die Erklärung zum Status 302 bzw. 307:
http://de.wikipedia.org/wiki/HTTP-St...XX_-_Umleitung

emsländer 9. Jul 2009 17:51

Re: Problem mit IdHTTP Exception 'HTTP/1.1 302 Moved Tempora
 
Zitat:

Zitat von shmia
Property HandleRedirects auf True setzen, dann folgt die Komponente der neuen URL.
Delphi-Quellcode:
httpcon.HandleRedirects := true;
Hier noch die Erklärung zum Status 302 bzw. 307:
http://de.wikipedia.org/wiki/HTTP-St...XX_-_Umleitung

Danke!


Gruss

EL


Alle Zeitangaben in WEZ +1. Es ist jetzt 06:04 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