From 1378bfee63d482d353d454b63636d686f346ae7e Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 23 Mar 2021 16:07:24 +0000 Subject: [PATCH] box: fix transfers getting stuck on token expiry after API change Box recently changed their API, changing the case of returned API items > On May 10th, 2021, as part of our continued infrastructure upgrade, > Box's API response headers will standardize to return in a case > insensitive manner, in line with industry best practices and our API > documentation. Applications that are using these headers, such as > "location" and "retry-after", will need to verify that their > applications are checking for these headers in a case-insensitive > fashion. Rclone was reading the raw headers from the `http.Header` and not using the `Get` accessor method which meant that it was sensitive to case changes. This fixes the problem by using the `Get` accessor method. See: https://forum.rclone.org/t/box-backend-incompatible-with-box-api-changes-being-deployed/22972 --- backend/box/box.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/box/box.go b/backend/box/box.go index 7a222b162..d47073703 100644 --- a/backend/box/box.go +++ b/backend/box/box.go @@ -323,7 +323,7 @@ func shouldRetry(ctx context.Context, resp *http.Response, err error) (bool, err } authRetry := false - if resp != nil && resp.StatusCode == 401 && len(resp.Header["Www-Authenticate"]) == 1 && strings.Index(resp.Header["Www-Authenticate"][0], "expired_token") >= 0 { + if resp != nil && resp.StatusCode == 401 && strings.Contains(resp.Header.Get("Www-Authenticate"), "expired_token") { authRetry = true fs.Debugf(nil, "Should retry: %v", err) }