Send HTTP Request

2019-02-17 10:30发布

问题:

Is there any way to send HTTP request using (pure) Inno Setup?

isxdl.dll isn't an option, because it creates window of the "download".

Also I would like to avoid using curl.

回答1:

This extension can download without a UI; http://www.sherlocksoftware.org/page.php?id=50 (Via ITD_DownloadFiles)



回答2:

Use WinHttpRequest object:

var
  WinHttpReq: Variant;
begin
  WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');
  WinHttpReq.Open('GET', 'https://www.example.com/', False);
  WinHttpReq.Send('');
  if WinHttpReq.Status <> 200 then
  begin
    Log(Format('HTTP error: %d %s', [Integer(WinHttpReq.Status), WinHttpReq.StatusText]));
  end
    else
  begin
    Log(Format('HTTP Response: %s', [WinHttpReq.ResponseText]));
  end;
end;