mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-03-08 16:39:29 +00:00
Several packages are only used while running the e2e suite. These packages are less important to update, as the they can not influence the final executable that is part of the Ceph-CSI container-image. By moving these dependencies out of the main Ceph-CSI go.mod, it is easier to identify if a reported CVE affects Ceph-CSI, or only the testing (like most of the Kubernetes CVEs). Signed-off-by: Niels de Vos <ndevos@ibm.com>
43 lines
913 B
Go
43 lines
913 B
Go
// Copyright 2019 The Gorilla WebSocket Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package websocket
|
|
|
|
import (
|
|
"io"
|
|
"strings"
|
|
)
|
|
|
|
// JoinMessages concatenates received messages to create a single io.Reader.
|
|
// The string term is appended to each message. The returned reader does not
|
|
// support concurrent calls to the Read method.
|
|
func JoinMessages(c *Conn, term string) io.Reader {
|
|
return &joinReader{c: c, term: term}
|
|
}
|
|
|
|
type joinReader struct {
|
|
c *Conn
|
|
term string
|
|
r io.Reader
|
|
}
|
|
|
|
func (r *joinReader) Read(p []byte) (int, error) {
|
|
if r.r == nil {
|
|
var err error
|
|
_, r.r, err = r.c.NextReader()
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
if r.term != "" {
|
|
r.r = io.MultiReader(r.r, strings.NewReader(r.term))
|
|
}
|
|
}
|
|
n, err := r.r.Read(p)
|
|
if err == io.EOF {
|
|
err = nil
|
|
r.r = nil
|
|
}
|
|
return n, err
|
|
}
|