mirror of
https://github.com/sorenisanerd/gotty.git
synced 2024-12-22 23:17:29 +00:00
Make sure we read the full message
This commit is contained in:
parent
82c3acf3b1
commit
1eed97f0f8
@ -1,7 +1,10 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type wsWrapper struct {
|
||||
@ -28,6 +31,11 @@ func (wsw *wsWrapper) Read(p []byte) (n int, err error) {
|
||||
continue
|
||||
}
|
||||
|
||||
return reader.Read(p)
|
||||
b, err := ioutil.ReadAll(reader)
|
||||
if len(b) > len(p) {
|
||||
return 0, errors.Wrapf(err, "Client message exceeded buffer size")
|
||||
}
|
||||
n = copy(p, b)
|
||||
return n, err
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user