From upstream: https://github.com/docker/distribution/commit/f9a05061916d095e95566d23e968608ee0576446