HTTP Socket

tutname=HTTP Socket|tutautor=[[:PsyCore]]|tutversion=1.0|tutquelle=

Code Template

alias urlencode { 
  var %a = $regsubex($$1,/([^\w\s])/Sg,$+(%,$base($asc(\t),10,16,2))) 
  return $replace(%a,$chr(32),$chr(43)) 
}
 
alias nfquery {
  sockopen nquery www.host.de 80
}
 
on *:SOCKOPEN:nquery:{
  var %nquery.var = msg= $+ $urlencode(%nquery.msg) $+ &nick= $+ $urlencode(%nquery.nick)
  var %nquery.host = www.host.de
  var %nquery.get = /push/push.php? $+ %nquery.var HTTP/1.1
  sockwrite -n nquery GET %nquery.get
  sockwrite -n nquery Host: %nquery.host 
  sockwrite -n nquery $crlf
}
 
on *:sockwrite:nquery: {
  unset %nquery.nick
  unset %nquery.msg
  sockclose nquery
} 
 
on *:open:?: {
  set %nquery.nick $nick
  set %nquery.msg $1-
  nfquery
}