diff options
| author | MatthieuCoder <matthieu@matthieu-dev.xyz> | 2023-01-04 23:13:05 +0400 | 
|---|---|---|
| committer | MatthieuCoder <matthieu@matthieu-dev.xyz> | 2023-01-04 23:13:05 +0400 | 
| commit | 63565094f480154556be69a6b3625e47c3b28f04 (patch) | |
| tree | d8fcccbd7f671e73477137373089a63e130337eb /exes/rest | |
| parent | 327ed3ca02400d1ff639925fa809e09ac3fc489c (diff) | |
ignore headers that are not 'Bot' headers
Diffstat (limited to 'exes/rest')
| -rw-r--r-- | exes/rest/src/handler.rs | 22 | 
1 files changed, 16 insertions, 6 deletions
diff --git a/exes/rest/src/handler.rs b/exes/rest/src/handler.rs index 3828154..004f763 100644 --- a/exes/rest/src/handler.rs +++ b/exes/rest/src/handler.rs @@ -106,11 +106,21 @@ pub async fn handle_request(      request.headers_mut().remove("proxy-connection");      request.headers_mut().remove(TRANSFER_ENCODING);      request.headers_mut().remove(UPGRADE); -    request.headers_mut().remove(AUTHORIZATION); -    request.headers_mut().append( -        AUTHORIZATION, -        HeaderValue::from_str(&format!("Bot {}", token))?, -    ); +     +    if let Some(auth) = request.headers_mut().get_mut(AUTHORIZATION) { +        if auth +            .to_str() +            .expect("Failed to check header") +            .starts_with("Bot") +        { +            *auth = HeaderValue::from_str(&format!("Bot {}", token))?; +        } +    } else { +        request.headers_mut().insert( +            AUTHORIZATION, +            HeaderValue::from_str(&format!("Bot {}", token))?, +        ); +    }      let uri = match Uri::from_str(&uri_string) {          Ok(uri) => uri, @@ -139,7 +149,7 @@ pub async fn handle_request(          "X-Upstream-Ms",          HeaderValue::from_str(&upstream_time_took.as_millis().to_string()).unwrap(),      ); -     +      let ratelimit_headers = resp          .headers()          .into_iter()  | 
