|
@@ -80,7 +80,7 @@ type Session struct {
|
|
|
// or to directly send a header
|
|
|
type sendReady struct {
|
|
|
Hdr []byte
|
|
|
- Body io.Reader
|
|
|
+ Body []byte
|
|
|
Err chan error
|
|
|
}
|
|
|
|
|
@@ -352,7 +352,7 @@ func (s *Session) keepalive() {
|
|
|
}
|
|
|
|
|
|
// waitForSendErr waits to send a header, checking for a potential shutdown
|
|
|
-func (s *Session) waitForSend(hdr header, body io.Reader) error {
|
|
|
+func (s *Session) waitForSend(hdr header, body []byte) error {
|
|
|
errCh := make(chan error, 1)
|
|
|
return s.waitForSendErr(hdr, body, errCh)
|
|
|
}
|
|
@@ -360,7 +360,7 @@ func (s *Session) waitForSend(hdr header, body io.Reader) error {
|
|
|
// waitForSendErr waits to send a header with optional data, checking for a
|
|
|
// potential shutdown. Since there's the expectation that sends can happen
|
|
|
// in a timely manner, we enforce the connection write timeout here.
|
|
|
-func (s *Session) waitForSendErr(hdr header, body io.Reader, errCh chan error) error {
|
|
|
+func (s *Session) waitForSendErr(hdr header, body []byte, errCh chan error) error {
|
|
|
t := timerPool.Get()
|
|
|
timer := t.(*time.Timer)
|
|
|
timer.Reset(s.config.ConnectionWriteTimeout)
|
|
@@ -440,7 +440,7 @@ func (s *Session) send() {
|
|
|
|
|
|
// Send data from a body if given
|
|
|
if ready.Body != nil {
|
|
|
- _, err := io.Copy(s.conn, ready.Body)
|
|
|
+ _, err := s.conn.Write(ready.Body)
|
|
|
if err != nil {
|
|
|
s.logger.Printf("[ERR] yamux: Failed to write body: %v", err)
|
|
|
asyncSendErr(ready.Err, err)
|