use as_bytes() instead of b
This commit is contained in:
12
src/main.rs
12
src/main.rs
@ -187,7 +187,8 @@ fn parse_field_lines(
|
|||||||
reader.read_line(&mut line).unwrap();
|
reader.read_line(&mut line).unwrap();
|
||||||
|
|
||||||
if !line.ends_with("\r\n") {
|
if !line.ends_with("\r\n") {
|
||||||
b"Lines need to end with a CRLF"
|
"Lines need to end with a CRLF"
|
||||||
|
.as_bytes()
|
||||||
.iter()
|
.iter()
|
||||||
.for_each(|byte| response_body.push(*byte));
|
.for_each(|byte| response_body.push(*byte));
|
||||||
|
|
||||||
@ -212,7 +213,8 @@ fn parse_field_lines(
|
|||||||
let field_line = match line.split_once(":") {
|
let field_line = match line.split_once(":") {
|
||||||
Some(val) => val,
|
Some(val) => val,
|
||||||
None => {
|
None => {
|
||||||
b"Invalid field-line"
|
"Invalid field-line"
|
||||||
|
.as_bytes()
|
||||||
.iter()
|
.iter()
|
||||||
.for_each(|byte| response_body.push(*byte));
|
.for_each(|byte| response_body.push(*byte));
|
||||||
|
|
||||||
@ -236,7 +238,8 @@ fn parse_field_lines(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !field_lines.contains_key(&String::from("Host")) {
|
if !field_lines.contains_key(&String::from("Host")) {
|
||||||
b"field-line with key HOST is missing"
|
"field-line with key HOST is missing"
|
||||||
|
.as_bytes()
|
||||||
.iter()
|
.iter()
|
||||||
.for_each(|byte| response_body.push(*byte));
|
.for_each(|byte| response_body.push(*byte));
|
||||||
|
|
||||||
@ -372,7 +375,8 @@ fn handle_request(mut stream: TcpStream) -> Result<(), Box<dyn Error>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if line.ends_with(" ") {
|
if line.ends_with(" ") {
|
||||||
b"There is whitespace between the start-line and the first field-line"
|
"There is whitespace between the start-line and the first field-line"
|
||||||
|
.as_bytes()
|
||||||
.iter()
|
.iter()
|
||||||
.for_each(|byte| response_body.push(*byte));
|
.for_each(|byte| response_body.push(*byte));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user