Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
gi0baro committed Jan 25, 2024
1 parent 6a76ac1 commit 6d00b52
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/asgi/types.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use hyper::{
header::{self, HeaderMap},
http::uri::Authority,
Uri, Version,
};
use percent_encoding::percent_decode_str;
Expand Down Expand Up @@ -109,7 +110,7 @@ impl ASGIScope {
))?;
}
if !self.headers.contains_key(header::HOST) {
let host = self.uri.authority().map(|v| v.as_str()).unwrap_or("");
let host = self.uri.authority().map_or("", Authority::as_str);
rv.insert(0, (PyBytes::new(py, b"host"), PyBytes::new(py, host.as_bytes())))?;
}
Ok(rv)
Expand Down
3 changes: 2 additions & 1 deletion src/wsgi/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use http_body_util::BodyExt;
use hyper::{
body::Bytes,
header::{HeaderMap, CONTENT_LENGTH, CONTENT_TYPE, HOST},
http::uri::Authority,
Method, Uri, Version,
};
use percent_encoding::percent_decode_str;
Expand Down Expand Up @@ -174,7 +175,7 @@ impl WSGIScope {
));
}
if !self.headers.contains_key(HOST) {
let host = self.uri.authority().map(|v| v.as_str()).unwrap_or("");
let host = self.uri.authority().map_or("", Authority::as_str);
headers.push(("HTTP_HOST".to_string(), host));
}

Expand Down

0 comments on commit 6d00b52

Please sign in to comment.