Run rustfmt

This commit is contained in:
2021-05-15 23:24:12 +02:00
parent 676c4e7a18
commit a8c6962b20
7 changed files with 156 additions and 144 deletions

View File

@ -1,11 +1,11 @@
mod consts;
mod parser;
mod handler;
mod parser;
use std::net::TcpStream;
use openssl::ssl::SslStream;
use std::io::{Write, Read};
use std::fmt::Formatter;
use std::io::{Read, Write};
use std::net::TcpStream;
pub use handler::*;
@ -86,7 +86,7 @@ impl StatusClass {
300..=399 => StatusClass::Redirection,
400..=499 => StatusClass::ClientError,
500..=599 => StatusClass::ServerError,
_ => panic!("invalid status code")
_ => panic!("invalid status code"),
}
}
}
@ -106,7 +106,7 @@ impl Status {
code: status_code,
message: msg.to_string(),
class: class.clone(),
}
};
}
}
panic!("invalid status code");
@ -124,7 +124,6 @@ impl Status {
}
}
pub struct HeaderField {
name: String,
value: String,
@ -140,13 +139,13 @@ pub struct Request {
version: String,
method: Method,
uri: String,
header_fields: Vec<HeaderField>
header_fields: Vec<HeaderField>,
}
pub struct Response {
version: String,
status: Status,
header_fields: Vec<HeaderField>
header_fields: Vec<HeaderField>,
}
impl Response {
@ -170,7 +169,10 @@ impl Response {
}
fn send(&self, stream: &mut Stream) -> Result<(), std::io::Error> {
let mut header = format!("HTTP/{} {:03} {}\r\n", self.version, self.status.code, self.status.message);
let mut header = format!(
"HTTP/{} {:03} {}\r\n",
self.version, self.status.code, self.status.message
);
for header_field in &self.header_fields {
header.push_str(format!("{}: {}\r\n", header_field.name, header_field.value).as_str());
}