$urlget » History » Version 14
Per Amundsen, 04/12/2023 04:29 PM
1 | 1 | Per Amundsen | _Added in 3.6_ |
---|---|---|---|
2 | |||
3 | 13 | Per Amundsen | *$urlget(N/id/url,options,target,alias,headers,body)* |
4 | 1 | Per Amundsen | |
5 | 4 | Per Amundsen | Performs a GET/POST request to a http server and returns a unique id to identify the request. |
6 | 1 | Per Amundsen | |
7 | 4 | Per Amundsen | When the request is finished, calls the specified alias with the id as a parameter. |
8 | 1 | Per Amundsen | |
9 | 7 | Per Amundsen | _Files downloaded with the 'f' parameter will use the folder matching the file extension from [[Dcc_Options#Dcc-Get-Folders|Dcc Get Folders]] or the [[Dcc_Options#Default-download-dir|default Dcc Get Folder]]._ |
10 | |||
11 | 1 | Per Amundsen | *Parameters* |
12 | |||
13 | 13 | Per Amundsen | table(ktable). |
14 | |*Parameter*|*Description*| |
||
15 | | N | If N = 0, returns the Nth running request, otherwise the Nth running request. | |
||
16 | | id | Returns the running request matching the id. | |
||
17 | | url | The "url":https://en.wikipedia.org/wiki/URL to perform the GET/POST request to. | |
||
18 | | Options | Url get options. | |
||
19 | | target | The target &binvar or filename to save the response. | |
||
20 | | alias | The alias to perform when the request is completed. | |
||
21 | | headers | &binvar containing addiotional headers separated by [[$crlf]]. (optional) | |
||
22 | | body | &binvar containing POST data, used with the "p" switch. (optional) | |
||
23 | 1 | Per Amundsen | |
24 | 13 | Per Amundsen | *Options* |
25 | 1 | Per Amundsen | |
26 | 13 | Per Amundsen | table(ktable). |
27 | |*Option*|*Description*| |
||
28 | | g | Perform a GET request. | |
||
29 | | p | Perform a POST request. | |
||
30 | | f | Save the response to a file. | |
||
31 | | b | Save the response to a &binvar. | |
||
32 | | r | Resume a failed request/download. | |
||
33 | | t | *TODO* | |
||
34 | | c | Cancel a running request. | |
||
35 | | k | Disable url/header redirect. | |
||
36 | 14 | Per Amundsen | | S | Ignore SSL/TLS certificate errors. *(AdiIRC Only)* | |
37 | 13 | Per Amundsen | |
38 | 1 | Per Amundsen | *Properties* |
39 | |||
40 | 13 | Per Amundsen | table(ktable). |
41 | |*Property*|*Description*| |
||
42 | | .url | Returns the url used. | |
||
43 | | .redirect | Returns the value of the location header if available. | |
||
44 | | .method | Returns the method used (GET/POST). | |
||
45 | | .type | Returns the type of output, (binvar/file). | |
||
46 | | .target | Returns the value of target (name of the binvar or filename). | |
||
47 | | .alias | Returns the name of the alias used. | |
||
48 | | .id | Returns the unique request id. | |
||
49 | | .state | Returns the state (ok, connect, download, fail). | |
||
50 | | .size | Returns the value of the Content-Lenght header. | |
||
51 | | .resume | Returns the number of bytes to resume from a failed request/download. | |
||
52 | | .rcvd | Returns the number of bytes received after the header, could be different from .size after a failed download. | |
||
53 | | .time | Returns the time taken to complete the processing, in milliseconds. | |
||
54 | | .reply | Returns the response headers. | |
||
55 | 10 | Per Amundsen | |
56 | *Example* |
||
57 | |||
58 | <pre> |
||
59 | 1 | Per Amundsen | ; Perform a GET request to adiirc.com and put the result in '&target' binvar. |
60 | 6 | Per Amundsen | //noop $urlget(https://adiirc.com,gb,&target,callback) |
61 | 1 | Per Amundsen | |
62 | ; Or Perform a POST request to adiirc.com and put the result in '&target' binvar. |
||
63 | alias posttest { |
||
64 | bset -t &header 1 Test: Header |
||
65 | bset -t &body 1 foo1=bar1&foo2=bar2 |
||
66 | noop $urlget(https://adiirc.com,pb,&target,callback,&header,&body) |
||
67 | } |
||
68 | |||
69 | ; When a request is finished, print the result. |
||
70 | alias callback { |
||
71 | 8 | Per Amundsen | echo -ag Response: $bvar($urlget($1).target,1-).text |
72 | } |
||
73 | |||
74 | 9 | Per Amundsen | ; List the number of running requests. |
75 | 8 | Per Amundsen | //echo -ag $urlget(0) |
76 | 1 | Per Amundsen | |
77 | ; List the first running request. |
||
78 | //echo -ag $urlget(1) |
||
79 | |||
80 | ; Cancel the first running request. |
||
81 | //echo -ag $urlget(1, c) |
||
82 | |||
83 | ; Download the latest AdiIRC beta. |
||
84 | ; Notice the 'target' parameter is left blank so it will use the original filename from the server. |
||
85 | ; Also notice the 'alias' parameter is set to /noop to ignore the callback. |
||
86 | //noop $urlget(https://adiirc.com/AdiIRC64_45.exe,gf,,/noop) |
||
87 | </pre> |