Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program synapse_https_get_test;
- uses ssl_openssl, // this include the use of the OpenSSL library.
- httpsend; // use synapse 40.1 found in the online package manager
- function DownloadHTTP(URL, TargetFile: string): Boolean;
- var
- HTTPGetResult: Boolean;
- HTTPSender: THTTPSend;
- begin
- Result := False;
- HTTPSender := THTTPSend.Create;
- try
- HTTPGetResult := HTTPSender.HTTPMethod('GET', URL);
- if (HTTPSender.ResultCode >= 100) and (HTTPSender.ResultCode<=299) then begin
- HTTPSender.Document.SaveToFile(TargetFile);
- Result := True;
- end;
- finally
- HTTPSender.Free;
- end;
- end;
- begin
- if DownloadHTTP('https://api.spacexdata.com/v3/capsules', 'capsules.json') then
- writeln('downloaded capsules.json')
- else
- writeln('FAILED downloading capsules.json');
- readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement