From WikiChip
Difference between revisions of "mirc/identifiers/$urlget"
(Created page with "{{mirc title|$urlget identifier}}'''$urlget''' sends a GET/POST to an http server. == Synopsis == <pre>$urlget()</pre> == Parameters == == Properties == == Example == <sou...") |
(→Example) |
||
Line 9: | Line 9: | ||
== Example == | == Example == | ||
+ | |||
+ | Type /urlget.test | ||
<source lang="mIRC">; > POST / HTTP/1.1 | <source lang="mIRC">; > POST / HTTP/1.1 | ||
; > Accept: */* | ; > Accept: */* |
Revision as of 17:32, 12 March 2019
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.
Synopsis
$urlget()
Parameters
Properties
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