code: func (buh *blobUploadHandler) blobUploadResponse(w http.ResponseWriter, r *http.Request, fresh bool) error {
  	// TODO(stevvooe): Need a better way to manage the upload state automatically.
  	buh.State.Name = buh.Repository.Named().Name()
  	buh.State.UUID = buh.Upload.ID()
  	buh.Upload.Close()
  	buh.State.Offset = buh.Upload.Size()
  	buh.State.StartedAt = buh.Upload.StartedAt()
  
  	token, err := hmacKey(buh.Config.HTTP.Secret).packUploadState(buh.State)
  	if err != nil {
  		dcontext.GetLogger(buh).Infof("error building upload state token: %s", err)
  		return err
  	}
  
  	uploadURL, err := buh.urlBuilder.BuildBlobUploadChunkURL(
  		buh.Repository.Named(), buh.Upload.ID(),
  		url.Values{
  			"_state": []string{token},
  		})
  	if err != nil {
  		dcontext.GetLogger(buh).Infof("error building upload url: %s", err)
  		return err
  	}
  
  	endRange := buh.Upload.Size()
  	if endRange > 0 {
  		endRange = endRange - 1
  	}
  
  	w.Header().Set("Docker-Upload-UUID", buh.UUID)
  	w.Header().Set("Location", uploadURL)
  
  	w.Header().Set("Content-Length", "0")
  	w.Header().Set("Range", fmt.Sprintf("0-%d", endRange))
  
  	return nil
  }
docs: // blobUploadResponse provides a standard request for uploading blobs and
  // chunk responses. This sets the correct headers but the response status is
  // left to the caller. The fresh argument is used to ensure that new blob
  // uploads always start at a 0 offset. This allows disabling resumable push by
  // always returning a 0 offset on check status.