// PipeRead returns a ReadCloser that's the logical concatenation of the provided input
// reader and the given ReadPipeline.
425045
func PipeRead(r io.ReadCloser, pipelines ...ReadPipeline) (io.ReadCloser, error) {
	pipes := []io.ReadCloser{r}
	for _, pipeline := range pipelines {
		r, err := pipeline(pipes[len(pipes)-1].(io.ReadCloser))
		if err != nil {
			return nil, err
		}
		pipes = append(pipes, r)
	}
	return &readPipe{
		pipes: pipes,
		pipe:  pipes[len(pipes)-1],
	}, nil
}
846881
func (d *Descriptor) HandleRead(h ReadHandler) {
	if d.Value != nil {
		panic("descriptor has been configured with a static value")
	}
	d.Property |= CharRead
	d.ReadHandler = h
}
951392
func (cw *wsReadWriteCloser) Read(p []byte) (n int, err error) {
	if cw.r != nil {
		// Check if previous reader still has data in the buffer.
		// Otherwise pass on to next reader.
		n, err = cw.r.Read(p)
		if err != io.EOF {
			return n, err
		}
	}
	_, r, err := cw.wsConn.NextReader()
	if err != nil {
		return 0, err
	}
	cw.r = r // Store reader for next call to Read.

	n, err = r.Read(p)
	return n, err
}
629476
func (m *Messenger) HandleRead(f ReadHandler) {
	m.readHandlers = append(m.readHandlers, f)
}
1196932
func OpenCloser(path string) (io.Closer, *zip.Reader, error) {
	file, err := os.Open(path)
	if err != nil {
		return nil, nil, err
	}
	finfo, err := file.Stat()
	if err != nil {
		return nil, nil, err
	}
	zr, err := NewReader(file, finfo.Size())
	if err != nil {
		return nil, nil, err
	}
	return file, zr, nil
}
1284445
func (r *tarReader) Close() error {
	if r.compressReader != nil {
		if err := r.compressReader.Close(); err != nil {
			return err
		}
	}

	if err := r.file.Close(); err != nil {
		return err
	}

	return nil
}
308820
func NewReaderCloser() (io.ReadCloser, error) {
	nl := unix.SockaddrNetlink{
		Family: unix.AF_NETLINK,
		// Passing Pid as 0 here allows the kernel to take care of assigning
		// it. This allows multiple netlink sockets to be used.
		Pid:    uint32(0),
		Groups: 1,
	}

	fd, err := unix.Socket(unix.AF_NETLINK, unix.SOCK_RAW, unix.NETLINK_KOBJECT_UEVENT)
	if err != nil {
		return nil, err
	}

	if err := unix.Bind(fd, &nl); err != nil {
		return nil, err
	}

	return &ReaderCloser{fd}, nil
}
638101
func closeReader(reader io.ReadCloser) {
	err := reader.Close()
	if err != nil {
		log.Println("Unable to close request Body")
	}
}
141577
func (o *MemoryObject) Reader() (io.ReadCloser, error) {
	return ioutil.NopCloser(bytes.NewBuffer(o.cont)), nil
}
396644
func (r *ReleaseReadCloser) Close() error {
	if r.ReadCloser != nil {
		return r.ReadCloser.Close()
	}
	return nil
}
146337
func (b *Buffer) ReadCloser() io.ReadCloser {
	ret := &readCloser{0, append(b.bufs, b.Buf)}

	b.bufs = nil
	b.toPool = nil
	b.Buf = nil

	return ret
}
82304
func (f ReadHandlerFunc) ServeRead(req Request, rsp ResponseWriter) {
	f(req, rsp)
}
865964
func makeReadCloser(r io.Reader, c io.Closer) io.ReadCloser {
	rc := struct {
		io.Reader
		io.Closer
	}{r, c}
	return io.ReadCloser(rc)
}
303008
func NewBufReader(r io.Reader) io.ReadCloser {
	timeout := rand.New(rndSrc).Intn(90)

	reader := &bufReader{
		buf:                  &bytes.Buffer{},
		drainBuf:             make([]byte, 1024),
		reuseBuf:             make([]byte, 4096),
		maxReuse:             1000,
		resetTimeout:         time.Duration(timeout) * time.Second,
		bufLenResetThreshold: 100 * 1024,
		maxReadDataReset:     10 * 1024 * 1024,
		reader:               r,
	}
	reader.wait.L = &reader.Mutex
	go reader.drain()
	return reader
}
352878
func (c *fileCacheable) ReadCloser() (io.ReadCloser, error) {
	// Check if the file has to be returned directly because
	// it is too large.
	if c.tooLarge {
		f, err := os.Open(c.fullname)
		if err != nil {
			return nil, errors.Annotate(err, ErrFileLoading, errorMessages, c.name)
		}
		return f, nil
	}
	// It's a cached buffer, so return this.
	return &fileBuffer{bytes.NewBuffer(c.data)}, nil
}
1082431
func (s *S3Provider) Reader(path ...string) (io.ReadCloser, error) {
	s3FilePath := strings.Join(path, "/")
	s3, err := storage.SafeCreateS3Bucket(s.S3Domain, s.BucketName, s.AccessKeyID, s.SecretAccessKey)

	if err != nil {
		return nil, err
	}
	return s3.NewReader(s3FilePath)
}
424725
func (r *PipeReader) CloseWithError(err error) error {
	if err == nil {
		err = io.ErrClosedPipe
	}
	r.bufpipe.l.Lock()
	defer r.bufpipe.l.Unlock()
	if r.bufpipe.rerr == nil {
		r.bufpipe.rerr = err
		r.bufpipe.rwait.Signal()
		r.bufpipe.wwait.Signal()
	}
	return nil
}