trim possible line terminators from message

This commit is contained in:
Austin 2015-11-03 13:37:32 -08:00
parent abc7c6a148
commit 34c369155c

View file

@ -5,6 +5,7 @@ package websocket
import ( import (
"bufio" "bufio"
"bytes"
"io" "io"
"net" "net"
"net/http" "net/http"
@ -224,7 +225,7 @@ func pumpStdout(conn *websocket.Conn, stdout io.Reader, done chan struct{}) {
s := bufio.NewScanner(stdout) s := bufio.NewScanner(stdout)
for s.Scan() { for s.Scan() {
conn.SetWriteDeadline(time.Now().Add(writeWait)) conn.SetWriteDeadline(time.Now().Add(writeWait))
if err := conn.WriteMessage(websocket.TextMessage, s.Bytes()); err != nil { if err := conn.WriteMessage(websocket.TextMessage, bytes.TrimSpace(s.Bytes())); err != nil {
break break
} }
} }