MCPcopy Create free account
hub / github.com/XTLS/Go / readFromUntil

Method readFromUntil

conn.go:899–910  ·  view source on GitHub ↗

readFromUntil reads from r into c.rawInput until c.rawInput contains at least n bytes or else returns an error.

(r io.Reader, n int)

Source from the content-addressed store, hash-verified

897// readFromUntil reads from r into c.rawInput until c.rawInput contains
898// at least n bytes or else returns an error.
899func (c *Conn) readFromUntil(r io.Reader, n int) error {
900 if c.rawInput.Len() >= n {
901 return nil
902 }
903 needs := n - c.rawInput.Len()
904 // There might be extra input waiting on the wire. Make a best effort
905 // attempt to fetch it so that it can be used in (*Conn).Read to
906 // "predict" closeNotify alerts.
907 c.rawInput.Grow(needs + bytes.MinRead)
908 _, err := c.rawInput.ReadFrom(&atLeastReader{r, int64(needs)})
909 return err
910}
911
912// sendAlert sends a TLS alert message.
913func (c *Conn) sendAlertLocked(err alert) error {

Callers 1

readRecordOrCCSMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected