aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/http/ratelimiting.rs32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/client/http/ratelimiting.rs b/src/client/http/ratelimiting.rs
index 00d6813..3518bdc 100644
--- a/src/client/http/ratelimiting.rs
+++ b/src/client/http/ratelimiting.rs
@@ -124,8 +124,10 @@ pub fn perform<'a, F>(route: Route, f: F) -> Result<Response>
// - then, perform the request
global.pre_hook();
- if let Some(route) = ROUTES.lock().expect("routes poisoned").get_mut(&route) {
- route.pre_hook();
+ if route != Route::None {
+ if let Some(route) = ROUTES.lock().expect("routes poisoned").get_mut(&route) {
+ route.pre_hook();
+ }
}
let response = try!(super::retry(&f));
@@ -144,18 +146,20 @@ pub fn perform<'a, F>(route: Route, f: F) -> Result<Response>
// so check if it did from the value of the 'x-ratelimit-limit'
// header. If the limit was 5 and is now 7, add 2 to the 'remaining'
- let redo = if response.headers.get_raw("x-ratelimit-global").is_some() {
- global.post_hook(&response)
- } else {
- ROUTES.lock()
- .expect("routes poisoned")
- .entry(route)
- .or_insert_with(RateLimit::default)
- .post_hook(&response)
- };
-
- if redo.unwrap_or(false) {
- continue;
+ if route != Route::None {
+ let redo = if response.headers.get_raw("x-ratelimit-global").is_some() {
+ global.post_hook(&response)
+ } else {
+ ROUTES.lock()
+ .expect("routes poisoned")
+ .entry(route)
+ .or_insert_with(RateLimit::default)
+ .post_hook(&response)
+ };
+
+ if redo.unwrap_or(false) {
+ continue;
+ }
}
return Ok(response);