Advertisement
Guest User

synapse_https_get_test.pas

a guest
Aug 12th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.82 KB | None | 0 0
  1. program synapse_https_get_test;
  2.  
  3. uses ssl_openssl, // this include the use of the OpenSSL library.
  4.   httpsend; // use synapse 40.1 found in the online package manager
  5.  
  6. function DownloadHTTP(URL, TargetFile: string): Boolean;
  7. var
  8.   HTTPGetResult: Boolean;
  9.   HTTPSender: THTTPSend;
  10. begin
  11.   Result := False;
  12.   HTTPSender := THTTPSend.Create;
  13.   try
  14.     HTTPGetResult := HTTPSender.HTTPMethod('GET', URL);
  15.     if (HTTPSender.ResultCode >= 100) and (HTTPSender.ResultCode<=299) then begin
  16.       HTTPSender.Document.SaveToFile(TargetFile);
  17.       Result := True;
  18.     end;
  19.   finally
  20.     HTTPSender.Free;
  21.   end;
  22. end;
  23.  
  24. begin
  25.   if DownloadHTTP('https://api.spacexdata.com/v3/capsules', 'capsules.json') then
  26.      writeln('downloaded capsules.json')
  27.   else
  28.     writeln('FAILED downloading capsules.json');
  29.   readln;
  30. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement