why does conn.Write ignoring the number bytes written?
Hi,
why does conn.Write ignoring the number bytes written here https://github.com/gobwas/ws/blob/master/write.go#L95 ? It seems to me that there is no guarantee net.Conn will write all the byes in one write call. if so, shouldn't the following function return both number of bytes and the error so the application can create ws continuation frames depending on the number of bytes written?
func WriteFrame(w io.Writer, f Frame) error {
err := WriteHeader(w, f.Header)
if err != nil {
return err
}
_, err = w.Write(f.Payload)
return err
}
while looking at the code I was wondering the same thing :)
No idea why it's written that way, now it's like this for historical reasons (we don't plan 2.x for now).
As a fix we can compare n with f.Payload and if they don't match - return an error.