Skip to content

Commit c3fb3d0

Browse files
committed
import just header module, not all used headers
1 parent c243033 commit c3fb3d0

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/main.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ mod expiring_lru;
33
mod ratelimiter_map;
44

55
use error::RequestError;
6-
use http::{
7-
HeaderValue, Method as HttpMethod, Uri,
8-
header::{AUTHORIZATION, CONNECTION, HOST, TRANSFER_ENCODING, UPGRADE},
9-
};
6+
use http::{HeaderValue, Method as HttpMethod, Uri, header};
107
use http_body_util::combinators::BoxBody;
118
use hyper::{
129
Request, Response,
@@ -40,8 +37,6 @@ use twilight_http_ratelimiting::{
4037
#[cfg(unix)]
4138
use tokio::signal::unix::{SignalKind, signal};
4239

43-
#[cfg(feature = "metrics")]
44-
use http::header::CONTENT_TYPE;
4540
#[cfg(feature = "metrics")]
4641
use http_body_util::{BodyExt, Full};
4742
#[cfg(feature = "metrics")]
@@ -358,21 +353,21 @@ async fn handle_request(
358353
};
359354

360355
request.headers_mut().insert(
361-
AUTHORIZATION,
356+
header::AUTHORIZATION,
362357
HeaderValue::from_bytes(token.as_bytes())
363358
.expect("strings are guaranteed to be valid utf-8"),
364359
);
365360
request
366361
.headers_mut()
367-
.insert(HOST, HeaderValue::from_static("discord.com"));
362+
.insert(header::HOST, HeaderValue::from_static("discord.com"));
368363

369364
// Remove forbidden HTTP/2 headers
370365
// https://datatracker.ietf.org/doc/html/rfc7540#section-8.1.2.2
371-
request.headers_mut().remove(CONNECTION);
366+
request.headers_mut().remove(header::CONNECTION);
372367
request.headers_mut().remove("keep-alive");
373368
request.headers_mut().remove("proxy-connection");
374-
request.headers_mut().remove(TRANSFER_ENCODING);
375-
request.headers_mut().remove(UPGRADE);
369+
request.headers_mut().remove(header::TRANSFER_ENCODING);
370+
request.headers_mut().remove(header::UPGRADE);
376371

377372
let mut uri_string = format!("https://discord.com{}{}", api_path, trimmed_path);
378373

@@ -443,7 +438,7 @@ async fn handle_request(
443438
fn handle_metrics(handle: Arc<PrometheusHandle>) -> Response<BoxBody<Bytes, hyper::Error>> {
444439
Response::builder()
445440
.header(
446-
CONTENT_TYPE,
441+
header::CONTENT_TYPE,
447442
HeaderValue::from_static("text/plain; version=0.0.4"),
448443
)
449444
.body(BoxBody::new(

0 commit comments

Comments
 (0)