github.com/kyma-project/kyma-environment-broker@v0.0.1/internal/iosafety/iosafety.go (about) 1 package iosafety 2 3 import ( 4 "io" 5 ) 6 7 // DrainReader reads and discards the remaining part in reader (for example response body data) 8 // In case of HTTP this ensured that the http connection could be reused for another request if the keepalive http connection behavior is enabled. 9 func DrainReader(reader io.Reader) error { 10 if reader == nil { 11 return nil 12 } 13 _, drainError := io.Copy(io.Discard, io.LimitReader(reader, 4096)) 14 return drainError 15 }