aboutsummaryrefslogtreecommitdiff
path: root/stream.go
diff options
context:
space:
mode:
authorGravatar Aliaksandr Valialkin <valyala@gmail.com> 2016-02-13 11:07:39 +0200
committerGravatar Aliaksandr Valialkin <valyala@gmail.com> 2016-02-13 11:07:39 +0200
commitcd2eb9bd90de46575d362cbec07246a1cd949dae (patch)
tree355f90570103da4eef29ed54e545854150cbf1c1 /stream.go
parentUse zero-alloc copy instead of io.Copy (diff)
downloadfasthttp-cd2eb9bd90de46575d362cbec07246a1cd949dae.tar.gz
fasthttp-cd2eb9bd90de46575d362cbec07246a1cd949dae.tar.bz2
fasthttp-cd2eb9bd90de46575d362cbec07246a1cd949dae.zip
Document that Close must be called on the reader returned from NewStreamReader
Diffstat (limited to 'stream.go')
-rw-r--r--stream.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/stream.go b/stream.go
index 377ff46..c7cb5a9 100644
--- a/stream.go
+++ b/stream.go
@@ -21,8 +21,11 @@ type StreamWriter func(w *bufio.Writer)
//
// The returned reader may be passed to Response.SetBodyStream.
//
+// Close must be called on the returned reader after after all the required data
+// has been read. Otherwise goroutine leak may occur.
+//
// See also Response.SetBodyStreamWriter.
-func NewStreamReader(sw StreamWriter) io.Reader {
+func NewStreamReader(sw StreamWriter) io.ReadCloser {
pr, pw := io.Pipe()
var bw *bufio.Writer