Is "\r\n--boundary" or "\n--boundary", depending
on what mode we are in. The comments below (and the name) assume
"\n--boundary", but either is accepted.
total: number
The number of bytes read out so far. If total == 0, then a
leading "--boundary" is recognized.
eof: boolean
Whether buf contains the final bytes in the stream before EOF.
If eof is false, more bytes are expected to follow.