AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Netzwerke Delphi indy idHttp + file download
Thema durchsuchen
Ansicht
Themen-Optionen

indy idHttp + file download

Ein Thema von sdean · begonnen am 28. Nov 2010 · letzter Beitrag vom 28. Nov 2010
Antwort Antwort
Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#1

AW: indy idHttp + file download

  Alt 28. Nov 2010, 20:55
Sure. Just handle the error.
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat
sdean

Registriert seit: 5. Dez 2009
64 Beiträge
 
#2

AW: indy idHttp + file download

  Alt 28. Nov 2010, 21:12
Sure. Just handle the error.
Thank you , But just how .
cause if i put handleRedirects property to False and idhttp faces an URL redirectios it will raise an exception with the Famous error http//1.1 302 found .
  Mit Zitat antworten Zitat
Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#3

AW: indy idHttp + file download

  Alt 28. Nov 2010, 21:19
Code:
try
 
excpet
  on NotFound
    jumpt to next download in queue
end;
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat
sdean

Registriert seit: 5. Dez 2009
64 Beiträge
 
#4

AW: indy idHttp + file download

  Alt 28. Nov 2010, 21:42
thank you Luckie
Here is my Thread Code :
Could you Fix it for me please . many thanks
Delphi-Quellcode:
procedure TFileDownThread.Execute;
var
  FStream: TFileStream;
  i:Integer;

begin

For i:=0 to FUrl.Count-1 do
  begin

  IdHTTP := TIdHTTP.Create(nil);
  try
    IdHTTP.Request.UserAgent := 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)';
    IdHTTP.OnWorkBegin := FWorkBeginEvent;
    IdHTTP.OnWork := FWorkEvent;
    IdHTTP.OnWorkEnd := FWorkEndevent;
    IdHTTP.HandleRedirects:=False;
   // IdHTTP.RedirectMaximum := 15;
   // Idhttp.OnRedirect:=OnRedirect;
    IdHTTP.Head(URL[i]);
    BytesInsgesamt := IdHTTP.Response.ContentLength;

    FStream:= TFileStream.Create(ExtractUrlFileName(URL[i]), fmCreate);
    IdHTTP.Get(URL[i], FStream);

  finally
    IdHTTP.Free;
    FStream.Free;
  
  end;
// Synchronize(ShowCode);
  end;
end;

Geändert von sdean (28. Nov 2010 um 21:44 Uhr)
  Mit Zitat antworten Zitat
Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#5

AW: indy idHttp + file download

  Alt 28. Nov 2010, 22:10
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
  i: Integer;
begin
  FileList := TStringList.Create;
  try
    FileList.Add('http://www.michael-puff.de/Programmierung/Delphi/Programme/AdressDB.zip');
    FileList.Add('http://www.michael-puff.de/Programmierung/Delphi/Programme/AdressDB_nonVCL.zip');
    FileList.Add('kdvndk');
    FileList.Add('http://www.michael-puff.de/Programmierung/Delphi/Programme/AudioPlayer.zip');
    for i := 0 to FileList.Count - 1 do
    begin
      try
        Download(i);
      except
        on E: EIdReadTimeOut do
        begin
          Memo1.Lines.Add(E.Message);
          Continue;
        end;
      end;
    end;
  finally
    FileList.Free
  end;
end;

procedure TForm1.Download(index: Integer);
begin
  IdHTTP1.Head(FileList[index]);
  Memo1.Lines.Add(IntToStr(IdHTTP1.Response.ContentLength));
end;
Just to show you the main principle.
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat
sdean

Registriert seit: 5. Dez 2009
64 Beiträge
 
#6

AW: indy idHttp + file download

  Alt 28. Nov 2010, 22:20
Thank you Luckie i will apply your Idea .
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:38 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz