Skip to content

Commit

Permalink
fix: request rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzofelletti committed Dec 10, 2024
1 parent de567cd commit d9d70a7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/http/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ impl fmt::Display for Request {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut headers_and_body = String::new();

if !matches!(self.authorization, Authorization::None) {}
if !matches!(self.authorization, Authorization::None) {
headers_and_body.push_str(format!("Authorization: {}\n", self.authorization).as_str());
}

for (header, value) in &self.headers {
headers_and_body.push_str(format!("{header}: {value}\n").as_str());
Expand All @@ -77,7 +79,7 @@ impl fmt::Display for Request {

write!(
f,
"{} {} {}\n{}",
"{} {} {}\n{}\n",
self.method, self.path, self.http_version, headers_and_body
)
}
Expand Down
4 changes: 2 additions & 2 deletions src/http/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ pub enum BasicAuthorization {
}

impl BasicAuthorization {
fn new(id: &str, password: &str) -> Self {
pub fn new(id: &str, password: &str) -> Self {
BasicAuthorization::IdPassword(id.to_owned(), password.to_owned())
}
fn new_encoded(encoded: &str) -> Self {
pub fn new_encoded(encoded: &str) -> Self {
BasicAuthorization::Encoded(encoded.to_owned())
}
}
Expand Down

0 comments on commit d9d70a7

Please sign in to comment.