-
Notifications
You must be signed in to change notification settings - Fork 1
/
CURL.b
49 lines (46 loc) · 1.52 KB
/
CURL.b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
SUBROUTINE CURL(url,headers,type,data,response)
*********************************************
* 2018-07-20 by Andrew Cole
*
* Tested Platforms:
* d3: Untested
* UniVerse: Untested
* UniData: Untested
* jBase: Works queryChar = @IM:'k'
* OpenQM: Untested
* mvBase: Works queryChar = '! '
*********************************************
queryChar = '! '
response = ''
curlCMD = 'C:\curl\curl -s '
validTypes = 'GET':@AM:'POST':@AM:'PUT':@AM:'DELETE'
LOCATE(type, validTypes; i) THEN
curlCommand = queryChar:curlCMD
curlCommand := '-X ':type:' '
curlCommand := url:' '
size = DCOUNT(headers, @AM)
FOR j=1 TO size
curlCommand := '-H "':headers<j>:'" '
NEXT j
IF data#'' THEN
size = DCOUNT(data, @AM)
FOR j=1 TO size
curlCommand := "-d '":data<j>:"' "
NEXT j
END
CRT curlCommand
EXECUTE 'CAP-HUSH-ON' ;* mvBase to hide terminal output
EXECUTE curlCommand CAPTURING rawResponse
EXECUTE 'CAP-HUSH-OFF' ;* mvBase to enable terminal output
size = DCOUNT(rawResponse, @AM)
FOR j=3 TO size
IF rawResponse<j>#'' THEN
IF NOT(INDEX(rawResponse<j>, '[!]>EXIT', 1)) THEN
response<-1> = rawResponse<j>
END
END
NEXT j
END ELSE
response = 0
END
RETURN