Re: corrupt zip download with Indy TidHTTP component

Posted by elias gonzalez on February 16, 2005 at 14:32:59:

In Reply to: corrupt zip download with Indy TidHTTP component posted by MrBe on January 17, 2005 at 16:10:56:

: Hey peoples.

: I creating a little app using Indy's HTTP component. TidHTTP. Ive been successful in downloading HTML which I have done many times, but have been having great trouble downloading zip files. It seems to get the right size data into a stream, but when I save this stream as a .zip, then try an extract it, it is corrupt.

: I have tried using a zipfix component (called TZipFix oddly enough ;-) ) which works to some extent but is inconsistent, sometimes only recovering some of the data. Maybe the data going into the stream has extra header characters which is making it seem corrupt when i save it, i dont know. Anyone with any experience with this?

: Here is an extract of my code.

: HTTP := TIdHTTP.Create(FOwner);
: HTTP.HandleRedirects := True;
: HTTP.AllowCookies := True;
: with HTTP do
: begin
: Request.UserAgent := 'Mozilla/4.0';
: Request.Connection := 'Keep-Alive';
: Request.ProxyConnection := 'Keep-Alive';
: Request.CacheControl := 'no-cache';
: end;
: Stream := TMemoryStream.Create;
: try
: HTTP.Request.Referer := ResultList.ValueFromIndex[sIndex];
: HTTP.Get(Url,Stream);
: if FileExists(GenFullPath(Name)) then DeleteFile(GenFullPath(Name));
: Stream.SaveToFile(GenFullPath(Name));
: except
: on e:exception do
: begin
: //error handling
: end;
: end;

: ----------end of extract-----------

: GenFullPath is simply a function i made to gen relevant file path using name of file downloaded.

: Regards, and thanks for your time,
: MrBe

[ Delphi Tutorials -- by DelphiLand ]