MCPcopy Create free account
hub / github.com/imroc/req / isKnownInMemoryReader

Function isKnownInMemoryReader

transfer.go:1016–1028  ·  view source on GitHub ↗

isKnownInMemoryReader reports whether r is a type known to not block on Read. Its caller uses this as an optional optimization to send fewer TCP packets.

(r io.Reader)

Source from the content-addressed store, hash-verified

1014// block on Read. Its caller uses this as an optional optimization to
1015// send fewer TCP packets.
1016func isKnownInMemoryReader(r io.Reader) bool {
1017 switch r.(type) {
1018 case *bytes.Reader, *bytes.Buffer, *strings.Reader:
1019 return true
1020 }
1021 if r, ok := unwrapNopCloser(r); ok {
1022 return isKnownInMemoryReader(r)
1023 }
1024 if r, ok := r.(*readTrackingBody); ok {
1025 return isKnownInMemoryReader(r.ReadCloser)
1026 }
1027 return false
1028}
1029
1030// bufioFlushWriter is an io.Writer wrapper that flushes all writes
1031// on its wrapped writer if it's a *bufio.Writer.

Callers 1

newTransferWriterFunction · 0.85

Calls 1

unwrapNopCloserFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…