Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix compatible with old servers when login 404 and other error handlerings. #524

Merged
merged 3 commits into from
Dec 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions core/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,9 @@ impl APIClient {
let response = self.query_request_helper(request, true, false).await;
let response = match response {
Ok(r) => r,
Err(Error::Logic(status, _ec)) if status == 404 => {
Err(Error::Logic(status, ..)) | Err(Error::Response { status, .. })
if status == 404 =>
{
// old server
return Ok(());
}
Expand Down Expand Up @@ -783,7 +785,7 @@ impl APIClient {
return Ok(response);
}
let body = response.bytes().await?;
if retry_if_503 || status == StatusCode::SERVICE_UNAVAILABLE {
if retry_if_503 && status == StatusCode::SERVICE_UNAVAILABLE {
// waiting for server to start
(Error::response_error(status, &body), true)
} else {
Expand Down Expand Up @@ -847,19 +849,15 @@ impl APIClient {
),
};
if !retry {
return Err(err.with_context(&format!(
"fail to {} {} after 3 reties",
request.method(),
request.url()
)));
return Err(err.with_context(&format!("{} {}", request.method(), request.url())));
}
match &err {
Error::AuthFailure(_) => {
if refreshed {
retries = 0;
} else if retries == 2 {
return Err(err.with_context(&format!(
"fail to {} {} after 3 reties",
"{} {} after 3 reties",
request.method(),
request.url()
)));
Expand All @@ -868,7 +866,7 @@ impl APIClient {
_ => {
if retries == 2 {
return Err(err.with_context(&format!(
"fail to {} {} after 3 reties",
"{} {} after 3 reties",
request.method(),
request.url()
)));
Expand Down
Loading