// Read reads up to len(p) bytes into p.
355838
func (w *wrapReadCloser) Read(p []byte) (int, error) {
	n, err := w.reader.Read(p)
	if err == io.ErrClosedPipe {
		return n, io.EOF
	}
	return n, err
}
116522
func (r *countReader) Read(p []byte) (int, error) {
	n, err := r.fr.Read(p)
	r.off += int64(n)
	return n, err
}
554162
func (r *UploadPackResponse) Read(p []byte) (int, error) {
	if r.r == nil {
		return 0, ErrUploadPackResponseNotDecoded
	}

	return r.r.Read(p)
}
780380
func (mt *MT19937) Read(p []byte) (n int, err error) {
	n = len(p)
	for len(p) >= 8 {
		val := mt.Uint64()
		p[0] = byte(val)
		p[1] = byte(val >> 8)
		p[2] = byte(val >> 16)
		p[3] = byte(val >> 24)
		p[4] = byte(val >> 32)
		p[5] = byte(val >> 40)
		p[6] = byte(val >> 48)
		p[7] = byte(val >> 56)
		p = p[8:]
	}
	if len(p) > 0 {
		val := mt.Uint64()
		for i := 0; i < len(p); i++ {
			p[i] = byte(val)
			val >>= 8
		}
	}
	return n, nil
}
685290
func (r *Reader) Read(p []byte) (int, error) {
	// If we haven't drawn before, initialize the progress bar
	if r.lastDraw.IsZero() {
		r.initProgress()
	}

	// Read from the underlying source
	n, err := r.Reader.Read(p)

	// Always increment the progress even if there was an error
	r.progress += int64(n)

	// If we don't have any errors, then draw the progress. If we are
	// at the end of the data, then finish the progress.
	if err == nil {
		// Only draw if we read data or we've never read data before (to
		// initialize the progress bar).
		if n > 0 {
			r.drawProgress()
		}
	}
	if err == io.EOF {
		r.finishProgress()
	}

	return n, err
}
688530
func (d *Decoder) Read(p []byte) (int, error) {
	if d.stream == nil {
		return 0, errors.New("no input has been initialized")
	}
	var n int
	for {
		if len(d.current.b) > 0 {
			filled := copy(p, d.current.b)
			p = p[filled:]
			d.current.b = d.current.b[filled:]
			n += filled
		}
		if len(p) == 0 {
			break
		}
		if len(d.current.b) == 0 {
			// We have an error and no more data
			if d.current.err != nil {
				break
			}
			d.nextBlock()
		}
	}
	if len(d.current.b) > 0 {
		// Only return error at end of block
		return n, nil
	}
	if d.current.err != nil {
		d.drainOutput()
	}
	if debug {
		println("returning", n, d.current.err, len(d.decoders))
	}
	return n, d.current.err
}
513790
func (b *Buffer) Read(p []byte) (n int, err error) {
	if b.off >= len(b.buf) {
		// Buffer is empty, reset to recover space.
		b.Truncate(0)
		if len(p) == 0 {
			return
		}
		return 0, io.EOF
	}
	n = copy(p, b.buf[b.off:])
	b.off += n
	return
}
167007
func (t *timeoutReader) Read(p []byte) (int, error) {
	// FIXME limit the amount of data read in one chunk so as to not exceed the timeout?
	// Do the read in the background
	type result struct {
		n   int
		err error
	}
	done := make(chan result, 1)
	go func() {
		n, err := t.reader.Read(p)
		done <- result{n, err}
	}()
	// Wait for the read or the timeout
	timer := time.NewTimer(t.timeout)
	defer timer.Stop()
	select {
	case r := <-done:
		return r.n, r.err
	case <-timer.C:
		t.cancel()
		return 0, TimeoutError
	}
	panic("unreachable") // for Go 1.0
}
431569
func (s *syntheticByteStream) Read(p []byte) (int, error) {
	s.mu.Lock()
	defer s.mu.Unlock()

	start := s.offset
	end := start + int64(len(p))
	var err error
	if end >= s.size {
		err = io.EOF
		end = s.size
	}

	for idx := start; idx < end; idx++ {
		p[idx-start] = s.factory(idx)
	}

	s.offset = end

	return int(end - start), err
}
652608
func (u readCloser) Read(p []byte) (n int, err error) {
	return u.reader.Read(p)
}
344201
func (m *multipartBody) Read(p []byte) (n int, err error) {
	if m.r == nil {
		r, w := io.Pipe()
		m.r = r

		var err error
		m.w, err = createWriter(w, &m.header)
		if err != nil {
			return 0, err
		}

		// Prevent calls to NextPart to succeed
		m.i = len(m.parts)

		go func() {
			if err := m.writeBodyTo(m.w); err != nil {
				w.CloseWithError(err)
				return
			}

			if err := m.w.Close(); err != nil {
				w.CloseWithError(err)
				return
			}

			w.Close()
		}()
	}

	return m.r.Read(p)
}
739337
func (c *CipherReader) Read(p []byte) (n int, err error) {
	n, err = c.r.Read(p)
	ws.Cipher(p[:n], c.mask, c.pos)
	c.pos += n
	return
}
992496
func (s spaceReader) Read(p []byte) (n int, err error) {
	// spaceLiterals is 16 ' ' bytes. It's used to speed up spaceReader's Read
	// method.
	const spaceLiterals = "                "
	for n < len(p) {
		m := copy(p[n:], spaceLiterals)
		if m == 0 {
			break
		}
		n += m
	}
	return n, nil
}
474324
func (acc *Accumulator) Read(p []byte) (n int, err error) {
	copy(p, acc.RandomData(uint(len(p))))
	return len(p), nil
}
1054816
func (f *FileReadSeeker) Read(p []byte) (int, error) {
	return f.file.Read(p)
}
287082
func (ar *abortableReader) Read(p []byte) (int, error) {
	select {
	case <-ar.abort:
		return 0, errors.New("download aborted")
	default:
	}
	return ar.r.Read(p)
}
900553
func (r *errorReader) Read(b []byte) (int, error) {
	if r.err != nil {
		return 0, r.err
	}
	var n int
	n, r.err = r.r.Read(b)
	return n, r.err
}