code: func copyDataToOutput(inputFactory func(io.Reader) (io.Reader, error),
  	adaptedInput *privateReaderAdapter,
  	output io.Writer,
  	shouldCloseDownstream bool) {
  
  	input, err := inputFactory(adaptedInput)
  
  	if err != nil {
  		adaptedInput.Writer.errChan <- err
  	} else {
  		_, err = io.Copy(output, input)
  		if err != nil {
  			adaptedInput.Writer.errChan <- err
  		}
  	}
  	writeCloser, ok := output.(io.WriteCloser)
  	if ok && shouldCloseDownstream {
  		closeErr := writeCloser.Close()
  		if closeErr != nil {
  			adaptedInput.Writer.errChan <- closeErr
  		}
  	}
  
  	// pulls all the data from the writer until EOF is reached
  	// this is because readers like zlib don't validate the CRC32
  	// (the last 4 bytes) in the normal codepath
  	adaptedInput.drain()
  
  	close(adaptedInput.Writer.errChan)
  }
docs: // This io.Copy's as much data as possible from the wrapped reader
  // to the corresponding writer output.
  // When finished it closes the downstream and drains the upstream
  // writer. Finally it sends any remaining errors to the errChan and
  // closes that channel