]> gitweb.factorcode.org Git - factor.git/blob - build-support/http-get.vbs
add targets to Nmakefile to fetch boot images on windows, add a wscript program to...
[factor.git] / build-support / http-get.vbs
1 if WScript.Arguments.Count < 2 then\r
2     WScript.Echo "usage: http-get.vbs source-url dest-file"\r
3     WScript.Quit 1\r
4 else\r
5     source_url = WScript.Arguments.Item(0)\r
6     dest_filename = WScript.Arguments.Item(1)\r
7 \r
8     dim http, source_data\r
9     set http = CreateObject("WinHttp.WinHttpRequest.5.1")\r
10     http.Open "GET", source_url, false\r
11     http.Send\r
12 \r
13     if http.Status = 200 then\r
14         dim dest_stream\r
15         set dest_stream = CreateObject("ADODB.Stream")\r
16 \r
17         dest_stream.Type = 1 ' adTypeBinary\r
18         dest_stream.Open\r
19         dest_stream.Write http.ResponseBody\r
20         dest_stream.SaveToFile dest_filename, 2 ' adSaveCreateOverWrite\r
21 \r
22         set dest_stream = nothing\r
23     else\r
24         WScript.Echo CStr(http.Status) + " " + http.StatusText + " when fetching " + source_url\r
25         WScript.Quit 1\r
26     end if\r
27 \r
28     set http = nothing\r
29 end if\r