Skip to content

Commit 7886e18

Browse files
committed
storage: fix redirect in registry backend
To fix #1720 Signed-off-by: imeoer <[email protected]>
1 parent e1dffec commit 7886e18

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

storage/src/backend/registry.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ const REGISTRY_CLIENT_ID: &str = "nydus-registry-client";
3131
const HEADER_AUTHORIZATION: &str = "Authorization";
3232
const HEADER_WWW_AUTHENTICATE: &str = "www-authenticate";
3333

34-
const REDIRECTED_STATUS_CODE: [StatusCode; 2] = [
35-
StatusCode::MOVED_PERMANENTLY,
36-
StatusCode::TEMPORARY_REDIRECT,
37-
];
38-
3934
const REGISTRY_DEFAULT_TOKEN_EXPIRATION: u64 = 10 * 60; // in seconds
4035

4136
/// Error codes related to registry storage backend operations.
@@ -724,9 +719,11 @@ impl RegistryReader {
724719
}
725720
};
726721
let status = resp.status();
722+
let need_redirect =
723+
status >= StatusCode::MULTIPLE_CHOICES && status < StatusCode::BAD_REQUEST;
727724

728725
// Handle redirect request and cache redirect url
729-
if REDIRECTED_STATUS_CODE.contains(&status) {
726+
if need_redirect {
730727
if let Some(location) = resp.headers().get("location") {
731728
let location = location.to_str().unwrap();
732729
let mut location = Url::parse(location)

0 commit comments

Comments
 (0)