Project

General

Profile

$urlget » History » Version 8

Per Amundsen, 07/10/2019 06:12 PM

1 1 Per Amundsen
_Added in 3.6_
2
3
*$urlget(N/id/url,gpfbrtc,target,alias,headers,body)*
4
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 3 Per Amundsen
N - If N = 0, returns the Nth running request, otherwise the Nth running request.
14 1 Per Amundsen
id - Returns the running request matching the id.
15
16
url - The "url":https://en.wikipedia.org/wiki/URL to perform the GET/POST request to.
17 2 Per Amundsen
gpfbrtc: 
18 1 Per Amundsen
g - Perform a GET request.
19
p - Perform a POST request.
20
f - Save the response to a file.
21
b - Save the response to a &binvar.
22
r - Resume a failed request/download.
23
t - TODO
24
c - Cancel a running request.
25
target - The target &binvar or filename to save the response.
26
alias - The alias to perform when the request is completed.
27
headers - &binvar containing addiotional headers separated by [[$crlf]]. (optional)
28
body - &binvar containing POST data, used with the "p" switch. (optional)
29
30
*Properties*
31
32
.url - Returns the url used.
33
.redirect - Returns the value of the location header if available.
34
.method - Returns the method used (GET/POST).
35
.type - Returns the type of output, (binvar/file).
36
.target - Returns the value of target (name of the binvar or filename).
37
.alias - Returns the name of the alias used.
38 4 Per Amundsen
.id - Returns the unique request id.
39 1 Per Amundsen
.state - Returns the state (ok, connect, download, fail).
40
.size - Returns the value of the Content-Lenght header.
41
.resume - Returns the number of bytes to resume from a failed request/download.
42
.rcvd - Returns the number of bytes received after the header, could be different from .size after a failed download.
43
.time - Returns the time taken to complete the processing, in milliseconds.
44
.reply - Returns the response headers.
45
46
*Example*
47
48
<pre>
49
; Perform a GET request to adiirc.com and put the result in '&target' binvar.
50
//noop $urlget(https://adiirc.com,gb,&target,callback)
51
52 5 Per Amundsen
; When the requested is finished, print the result.
53 1 Per Amundsen
alias callback {
54 6 Per Amundsen
  echo -ag Response: $bvar($urlget($1).target,1-).text
55 1 Per Amundsen
}
56
57
; List the number of running requests.
58
//echo -ag $urlget(0)
59
60
; List the first running request.
61
//echo -ag $urlget(1)
62
63
; Cancel the first running request.
64
//echo -ag $urlget(1, c)
65 8 Per Amundsen
66
; Download the latest AdiIRC beta.
67
; Notice the 'target' parameter is left blank so it will use the original filename from the server.
68
; Also notice the 'callback' parameter is set to /noop to ignore the callback.
69
//noop $urlget(https://adiirc.com/AdiIRC64_45.exe,gf,,/noop)
70 1 Per Amundsen
</pre>