diff --git a/src/http/request.rs b/src/http/request.rs index ea1638d..4a79ffe 100644 --- a/src/http/request.rs +++ b/src/http/request.rs @@ -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()); @@ -77,7 +79,7 @@ impl fmt::Display for Request { write!( f, - "{} {} {}\n{}", + "{} {} {}\n{}\n", self.method, self.path, self.http_version, headers_and_body ) } diff --git a/src/http/types.rs b/src/http/types.rs index 8e52dd9..89e8e2f 100644 --- a/src/http/types.rs +++ b/src/http/types.rs @@ -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()) } }