on *:sockopen:http.*:{
if (!$window(@http)) window -ek0 @http
if ($sockerr) || (!$sock($sockname)) return
if (/* !iswm $http.parse($hget(http,url)).path) { var %path / $+ $http.parse($hget(http,url)).path }
else { var %path $http.parse($hget(http,url)).path }
sockwrite -n $sockname $hget(http,method) %path HTTP/1.1
sockwrite -n $sockname Accept: */*
sockwrite -n $sockname Content-Type: application/x-www-form-urlencoded
sockwrite -n $sockname User-Agent: mIRC $version
sockwrite -n $sockname Host: $http.parse($hget(http,url)).host
sockwrite -n $sockname Content-Length: $len( $hget(http,data) )
sockwrite -n $sockname Connection: Keep-Alive
sockwrite -n $sockname Cache-Control: no-cache
sockwrite -n $sockname
if ($hget(http,method) == post) { sockwrite -n $sockname $hget(http,data) }
sockwrite -n $sockname $crlf $+ $crlf
}
on *:sockread:http.*:{
var %http.read
sockread %http.read
tokenize 32 %http.read
if (!$1) return
.signal -n http $1-
if (HTTP/1.* 200 OK iswm $1-) echo $color(info) -s HTTP $hget(http,method) request to $hget(http,url) successful!
while ($sockbr) {
if (*{"key":* iswm %http.read) {
unset %hastelink
var %hastekey = $gettok($gettok(%http.read,4,34),1,44)
set %hastelink http://hastebin.com/ $+ %hastekey
echo -s Key : %hastelink
}
sockread %http.read
}
}
on 1:sockclose:http.*:{
.signal -n http Connection to $sock($sockname).ip has been closed remotely
}
alias http {
if (!$regex($1-,(post|get) http://(.+)/(.*))) {
echo $color(info) -at Usage: /http <post|get> <url> [data]
echo $color(info) -at url has to match http://*/* and must not contain spaces!
return
}
hadd -m http url $2
hadd -m http method $upper($1)
if ($3) hadd http data $3-
if ($sock($+(http.,$1))) .sockclose $+(http.,$1)
sockopen $+(http.,$1) $http.parse($2).host 80
}
alias http.parse {
if ($regex($1-,^http://([^/]+)(/.*))) {
if ($prop == host) return $regml(1)
if ($prop == path) return $iif(($regml(2)),$regml(2),/)
}
}
on *:SIGNAL:http:{
/*
if (!$window(@http)) window -ek0 @http
echo @http < $1-
*/
/*
write http.log $1-
*/
}