mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 20:09:27 +02:00
* Cleanup should always be protected with try..finally
git-svn-id: trunk@5269 -
This commit is contained in:
parent
875eaa0fd6
commit
c7147a9412
@ -102,25 +102,27 @@ var
|
|||||||
URI: TURI;
|
URI: TURI;
|
||||||
begin
|
begin
|
||||||
FOutStream:=Dest;
|
FOutStream:=Dest;
|
||||||
{ parse URL }
|
Try
|
||||||
URI:=ParseURI(URL);
|
{ parse URL }
|
||||||
|
URI:=ParseURI(URL);
|
||||||
|
|
||||||
if URI.Port = 0 then
|
if URI.Port = 0 then
|
||||||
URI.Port := 21;
|
URI.Port := 21;
|
||||||
|
|
||||||
FFTP.Connect(URI.Host, URI.Port);
|
FFTP.Connect(URI.Host, URI.Port);
|
||||||
while not FFTP.Connected and not FQuit do
|
while not FFTP.Connected and not FQuit do
|
||||||
FFTP.CallAction;
|
|
||||||
|
|
||||||
if not FQuit then begin
|
|
||||||
FFTP.Authenticate(URI.Username, URI.Password);
|
|
||||||
FFTP.ChangeDirectory(URI.Path);
|
|
||||||
FFTP.Retrieve(URI.Document);
|
|
||||||
while not FQuit do
|
|
||||||
FFTP.CallAction;
|
FFTP.CallAction;
|
||||||
end;
|
|
||||||
|
|
||||||
FOutStream:=nil;
|
if not FQuit then begin
|
||||||
|
FFTP.Authenticate(URI.Username, URI.Password);
|
||||||
|
FFTP.ChangeDirectory(URI.Path);
|
||||||
|
FFTP.Retrieve(URI.Document);
|
||||||
|
while not FQuit do
|
||||||
|
FFTP.CallAction;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
FOutStream:=nil;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLNetDownloader.HTTPDownload(const URL: String; Dest: TStream);
|
procedure TLNetDownloader.HTTPDownload(const URL: String; Dest: TStream);
|
||||||
@ -128,22 +130,25 @@ var
|
|||||||
URI: TURI;
|
URI: TURI;
|
||||||
begin
|
begin
|
||||||
FOutStream:=Dest;
|
FOutStream:=Dest;
|
||||||
{ parse aURL }
|
Try
|
||||||
URI := ParseURI(URL);
|
{ parse aURL }
|
||||||
|
URI := ParseURI(URL);
|
||||||
|
|
||||||
if URI.Port = 0 then
|
if URI.Port = 0 then
|
||||||
URI.Port := 80;
|
URI.Port := 80;
|
||||||
|
|
||||||
FHTTP.Host := URI.Host;
|
FHTTP.Host := URI.Host;
|
||||||
FHTTP.Method := hmGet;
|
FHTTP.Method := hmGet;
|
||||||
FHTTP.Port := URI.Port;
|
FHTTP.Port := URI.Port;
|
||||||
FHTTP.URI := '/' + URI.Document;
|
FHTTP.URI := '/' + URI.Document;
|
||||||
FHTTP.SendRequest;
|
FHTTP.SendRequest;
|
||||||
|
|
||||||
FQuit:=False;
|
FQuit:=False;
|
||||||
while not FQuit do
|
while not FQuit do
|
||||||
FHTTP.CallAction;
|
FHTTP.CallAction;
|
||||||
FOutStream:=nil; // to be sure
|
Finally
|
||||||
|
FOutStream:=nil; // to be sure
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TLNetDownloader.Create(AOwner: TComponent);
|
constructor TLNetDownloader.Create(AOwner: TComponent);
|
||||||
|
Loading…
Reference in New Issue
Block a user