From WikiChip
$urlget identifier - mIRC
Commands & Identifiers
Basics
Events
Matching Tools
Data Storage
Control Structures
GUI Scripting
Sockets
Advanced Scripting
Additional Resources
Security
Other
$urlget sends a GET/POST to an http server. Returns an ID.
Synopsis
$urlget(url,gpfbrtc,target,alias,headers,body) $urlget(N/ID)[.prop]
Parameters
- url - the url to access, must be prefixed with http:// or https://
- gpfbrtc - switches to indicate how to proceed:
- gp - g for GET, p for POST
- fb - f to output the answer (without the responses headers) to a file, b to ouput to a binvar
- r' - resumes the processing
- t - uses .part file if necessary
- c - cancel the processing
- target - the filename if you used f, or a &binvar for b
- alias - the name of the alias that is called at the end, this alias is called as a command with one parameter passed to it: the ID
- headers - optional, a &binvar containing the headers to be sent, separated by $crlf
- body - optional, a &binvar containing the data to be sent when you are POSTing
- ID/N - the Nth urlget or the urlget referenced by the ID
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 ID.
- .state - returns the state (ok )
- .size - returns the size of the content-lenght header
- .resume - returns
- .rcvd -
- .time -
- .reply - returns the response headers
Example
Type /urlget.test
; > POST / HTTP/1.1 ; > Accept: */* ; > Test: Header ; > Accept-Encoding: gzip, deflate ; > User-Agent: mIRC ; > Host: localhost ; > Content-Length: 19 ; > Connection: Keep-Alive ; > Cache-Control: no-cache ; > foo1=bar1&foo2=bar2 ; < HTTP/1.1 200 OK ; < Connection: close ; < Content-Length: 5 ; < ; hello ; url http://localhost/ ; redirect http://localhost/ ; method post ; type binvar ; target &target ; alias urlget.callback ; id 1027 ; state ok ; size 5 ; resume 0 ; rcvd 5 ; time 125 ; reply HTTP/1.1 200 OK ; Connection: close ; Content-Length: 5 ; ; ; response hello alias urlget.test { urlget.listen var %url = $iif($1,$1,http://localhost/) bset -t &header 1 Test: Header bset -t &body 1 foo1=bar1&foo2=bar2 var %id = $urlget(%url,pb,&target,urlget.callback,&header,&body) } alias urlget.callback { var %id = $1 echo -agi9 url $urlget(%id).url echo -agi9 redirect $urlget(%id).redirect echo -agi9 method $urlget(%id).method echo -agi9 type $urlget(%id).type echo -agi9 target $urlget(%id).target echo -agi9 alias $urlget(%id).alias echo -agi9 id $urlget(%id).id echo -agi9 state $urlget(%id).state echo -agi9 size $urlget(%id).size echo -agi9 resume $urlget(%id).resume echo -agi9 rcvd $urlget(%id).rcvd echo -agi9 time $urlget(%id).time echo -agi9 reply $urlget(%id).reply if ($urlget(%id).type == binvar) { echo -agi9 response $bvar($urlget(%id).target,1-3000).text } } alias urlget.listen { if (!$sock(urlget.listen)) socklisten -d 127.0.0.1 urlget.listen 80 } on *:socklisten:urlget.listen:{ var %sockname = urlget.client. $+ $ticks if ($sock(%sockname)) return sockaccept %sockname } on *:sockread:urlget.client.*:{ var %header if (!$sock($sockname).mark) { sockread %header while (%header != $null) { echo 3 -ag > %header if ($regex(%header,Content-Length: (\d+))) { hadd -m $sockname content-length $regml(1) } sockread %header } if ($sockbr) sockmark $sockname $true } if ($sock($sockname).mark) && ($sock($sockname).rq) { sockread &read while ($sockbr) { hinc $sockname content-read $sockbr echo 6 -agi2 > $bvar(&read,1-3000).text sockread &read } } if ($hget($sockname,content-length) == 0) || ($v1 == $hget($sockname,content-read)) { socket.respond $sockname hello hfree -w $sockname } } alias -l sockwrite { echo 12 -ag < $3- sockwrite $1- } alias -l socket.respond { var %sockname = $$1, %data = $2- sockwrite -n %sockname HTTP/1.1 200 OK sockwrite -n %sockname Connection: close sockwrite -n %sockname Content-Length: $len(%data) sockwrite -n %sockname $+($crlf,%data) }
Compatibility
Added: mIRC v7.56
Added on: 06 Jul 2019
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.
See also
mIRC identifier list