Skip to content

Commit 35d320d

Browse files
author
Chao Xu
committed
Use the bufrw
Instead of the using the conn returned by the hijack, using the returned buffrw as the reader, because there can be unprocessed data sent by the client.
1 parent da0186e commit 35d320d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/agent/agentserver/tunnel.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (t *Tunnel) ServeHTTP(w http.ResponseWriter, r *http.Request) {
4949
}
5050
w.WriteHeader(http.StatusOK)
5151

52-
conn, _, err := hijacker.Hijack()
52+
conn, bufrw, err := hijacker.Hijack()
5353
if err != nil {
5454
http.Error(w, err.Error(), http.StatusInternalServerError)
5555
return
@@ -103,7 +103,7 @@ func (t *Tunnel) ServeHTTP(w http.ResponseWriter, r *http.Request) {
103103
pkt := make([]byte, 1<<12)
104104

105105
for {
106-
n, err := conn.Read(pkt[:])
106+
n, err := bufrw.Read(pkt[:])
107107
if err == io.EOF {
108108
klog.Warningf("EOF from %v", r.Host)
109109
break

0 commit comments

Comments
 (0)