diff options
author | Kornel <kornel@geekhood.net> | 2020-03-01 00:16:09 +0000 |
---|---|---|
committer | Kornel <kornel@geekhood.net> | 2020-03-01 00:16:09 +0000 |
commit | 43d93b46ab4151e17ffa9d8cc2a20566bd9ef955 (patch) | |
tree | cf3725beba087721fdc5b3091564aff81b45e390 | |
parent | 8a6b0f63f7536543640e684b99df2f7c537046cd (diff) |
Handle status 204
-rw-r--r-- | github_info/src/lib_github.rs | 4 | ||||
-rw-r--r-- | github_v3/src/lib.rs | 5 |
2 files changed, 5 insertions, 4 deletions
diff --git a/github_info/src/lib_github.rs b/github_info/src/lib_github.rs index d4fce62..1713c82 100644 --- a/github_info/src/lib_github.rs +++ b/github_info/src/lib_github.rs @@ -214,8 +214,8 @@ impl GitHub { _ => status.is_success(), }; let body = match res { - Some(res) => Some(res.obj().await?), - None => None, + Some(res) if !non_parsable_body => Some(res.obj().await?), + _ => None, }; match body.ok_or(Error::NoBody).and_then(|stats| { let dbg = format!("{:?}", stats); diff --git a/github_v3/src/lib.rs b/github_v3/src/lib.rs index 2ab19e7..36e498a 100644 --- a/github_v3/src/lib.rs +++ b/github_v3/src/lib.rs @@ -157,14 +157,15 @@ impl ClientInner { }; self.wait_sec.store(wait_sec, SeqCst); - if status == StatusCode::ACCEPTED && retries > 0 { + let should_wait_for_content = status == StatusCode::ACCEPTED; + if should_wait_for_content && retries > 0 { tokio::time::delay_for(Duration::from_secs(retry_delay)).await; retry_delay *= 2; retries -= 1; continue; } - return if status.is_success() && status != StatusCode::ACCEPTED { + return if status.is_success() && !should_wait_for_content { Ok(res) } else { Err(error_for_response(res).await) |