MCPcopy
hub / github.com/coder/websocket / extractBufioWriterBuf

Function extractBufioWriterBuf

write.go:413–426  ·  view source on GitHub ↗

extractBufioWriterBuf grabs the []byte backing a *bufio.Writer and returns it.

(bw *bufio.Writer, w io.Writer)

Source from the content-addressed store, hash-verified

411// extractBufioWriterBuf grabs the []byte backing a *bufio.Writer
412// and returns it.
413func extractBufioWriterBuf(bw *bufio.Writer, w io.Writer) []byte {
414 var writeBuf []byte
415 bw.Reset(util.WriterFunc(func(p2 []byte) (int, error) {
416 writeBuf = p2[:cap(p2)]
417 return len(p2), nil
418 }))
419
420 bw.WriteByte(0)
421 bw.Flush()
422
423 bw.Reset(w)
424
425 return writeBuf
426}
427
428func (c *Conn) writeError(code StatusCode, err error) {
429 c.writeClose(code, err.Error())

Callers 1

newConnFunction · 0.85

Calls 1

WriterFuncFuncType · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…