From upstream: https://github.com/docker/distribution/commit/5afbf324000f8c9675ef02b9a7f88948f0c82a0e