code: func (r *Session) GetRemoteImageLayer(imgID, registry string, imgSize int64) (io.ReadCloser, error) {
  	var (
  		statusCode = 0
  		res        *http.Response
  		err        error
  		imageURL   = fmt.Sprintf("%simages/%s/layer", registry, imgID)
  	)
  
  	req, err := http.NewRequest("GET", imageURL, nil)
  	if err != nil {
  		return nil, fmt.Errorf("Error while getting from the server: %v", err)
  	}
  
  	res, err = r.client.Do(req)
  	if err != nil {
  		logrus.Debugf("Error contacting registry %s: %v", registry, err)
  		// the only case err != nil && res != nil is https://golang.org/src/net/http/client.go#L515
  		if res != nil {
  			if res.Body != nil {
  				res.Body.Close()
  			}
  			statusCode = res.StatusCode
  		}
  		return nil, fmt.Errorf("Server error: Status %d while fetching image layer (%s)",
  			statusCode, imgID)
  	}
  
  	if res.StatusCode != 200 {
  		res.Body.Close()
  		return nil, fmt.Errorf("Server error: Status %d while fetching image layer (%s)",
  			res.StatusCode, imgID)
  	}
  
  	if res.Header.Get("Accept-Ranges") == "bytes" && imgSize > 0 {
  		logrus.Debug("server supports resume")
  		return resumable.NewRequestReaderWithInitialResponse(r.client, req, 5, imgSize, res), nil
  	}
  	logrus.Debug("server doesn't support resume")
  	return res.Body, nil
  }
docs: // GetRemoteImageLayer retrieves an image layer from the registry