$urlget » History » Revision 8
« Previous |
Revision 8/16
(diff)
| Next »
Per Amundsen, 07/10/2019 06:12 PM
Added in 3.6
$urlget(N/id/url,gpfbrtc,target,alias,headers,body)
Performs a GET/POST request to a http server and returns a unique id to identify the request.
When the request is finished, calls the specified alias with the id as a parameter.
Files downloaded with the 'f' parameter will use the folder matching the file extension from Dcc Get Folders or the default Dcc Get Folder.
Parameters
N - If N = 0, returns the Nth running request, otherwise the Nth running request.
id - Returns the running request matching the id.
url - The url to perform the GET/POST request to.
gpfbrtc:
g - Perform a GET request.
p - Perform a POST request.
f - Save the response to a file.
b - Save the response to a &binvar.
r - Resume a failed request/download.
t - TODO
c - Cancel a running request.
target - The target &binvar or filename to save the response.
alias - The alias to perform when the request is completed.
headers - &binvar containing addiotional headers separated by $crlf. (optional)
body - &binvar containing POST data, used with the "p" switch. (optional)
Properties
.url - Returns the url used.
.redirect - Returns the value of the location header if available.
.method - Returns the method used (GET/POST).
.type - Returns the type of output, (binvar/file).
.target - Returns the value of target (name of the binvar or filename).
.alias - Returns the name of the alias used.
.id - Returns the unique request id.
.state - Returns the state (ok, connect, download, fail).
.size - Returns the value of the Content-Lenght header.
.resume - Returns the number of bytes to resume from a failed request/download.
.rcvd - Returns the number of bytes received after the header, could be different from .size after a failed download.
.time - Returns the time taken to complete the processing, in milliseconds.
.reply - Returns the response headers.
Example
; Perform a GET request to adiirc.com and put the result in '&target' binvar. //noop $urlget(https://adiirc.com,gb,&target,callback) ; When the requested is finished, print the result. alias callback { echo -ag Response: $bvar($urlget($1).target,1-).text } ; List the number of running requests. //echo -ag $urlget(0) ; List the first running request. //echo -ag $urlget(1) ; Cancel the first running request. //echo -ag $urlget(1, c) ; Download the latest AdiIRC beta. ; Notice the 'target' parameter is left blank so it will use the original filename from the server. ; Also notice the 'callback' parameter is set to /noop to ignore the callback. //noop $urlget(https://adiirc.com/AdiIRC64_45.exe,gf,,/noop)
Updated by Per Amundsen about 5 years ago · 8 revisions