Skip to content

Instantly share code, notes, and snippets.

@adnan360
Last active March 13, 2019 10:17
Show Gist options
  • Save adnan360/bd5e9f1b770804ec23887692307c7864 to your computer and use it in GitHub Desktop.
Save adnan360/bd5e9f1b770804ec23887692307c7864 to your computer and use it in GitHub Desktop.
Get URL Content in Lazarus - using TFPHttpClient
function FPHTTPClientDownload(URL: string; SaveToFile: boolean = false; Filename: string = ''): string;
begin
Result := '';
With TFPHttpClient.Create(Nil) do
try
try
if SaveToFile then begin
Get(URL, Filename);
Result := Filename;
end else begin
Result := Get(URL);
end;
except
on E: Exception do
ShowMessage('Error: ' + E.Message);
end;
finally
Free;
end;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment