This is what I have so far:

Code:
on *:sockread:blah:{
  if ($sockerr) return
  :read
  sockread -fn &a
  if (!$sockbr) return
  if (!$bvar(&a,1,2).text) {
    echo -s YES
    if (!%headerend) { set %headerend $true }
  }
  if (%headerend) { fwrite -b a &a }
  goto read
}


It skips a couple of the first lines needed, any suggestions?