camallo / dkregistry-rs

A pure-Rust asynchronous library for Docker Registry API v2
Apache License 2.0
62 stars 39 forks source link

v2/client: friction around insecure registries and the `is_v2_supported` method #89

Closed steveej closed 5 years ago

steveej commented 5 years ago

IMHO the result of the is_v2_supported() method isn't correct as it is. In case of querying a v2-supported registry via plain http, the 301 status code (MOVED) will cause the method to return false to indicate that v2 is not supported here. The correct behavior would be look at the new URL and if the scheme changed to https, instead of returning false, throw an error which reports that the requested scheme is not supported.

I'll go ahead and call this a bug, but I'd like to know the original motivation behind this in case I'm missing something.

lucab commented 5 years ago

The original motivation is that specs do not contemplate redirection there: https://docs.docker.com/registry/spec/api/#api-version-check

However I do agree that for a client to be helpful it should be able to handle redirections on most of the paths. Also, all common registries seems to have a redirection in place for HTTP to HTTPS.