reorder code
This commit is contained in:
19
src/main.rs
19
src/main.rs
@ -150,14 +150,6 @@ fn parse_start_line(input: &str) -> Result<StartLine, Vec<u8>> {
|
|||||||
None,
|
None,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// start_line.method will remain RequestMethods::NULL if it is not supported.
|
|
||||||
match method {
|
|
||||||
"GET" => start_line.method = RequestMethods::Get,
|
|
||||||
"HEAD" => start_line.method = RequestMethods::Head,
|
|
||||||
_ => start_line.method = RequestMethods::Null,
|
|
||||||
}
|
|
||||||
|
|
||||||
if !StartLine::is_valid_version(version) {
|
if !StartLine::is_valid_version(version) {
|
||||||
return Err(response_builder(
|
return Err(response_builder(
|
||||||
RequestMethods::Head,
|
RequestMethods::Head,
|
||||||
@ -166,7 +158,6 @@ fn parse_start_line(input: &str) -> Result<StartLine, Vec<u8>> {
|
|||||||
None,
|
None,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if version != "HTTP/1.1" && version != "HTTP/1.0" {
|
if version != "HTTP/1.1" && version != "HTTP/1.0" {
|
||||||
"Server only supports major version 1 of HTTP"
|
"Server only supports major version 1 of HTTP"
|
||||||
.as_bytes()
|
.as_bytes()
|
||||||
@ -186,9 +177,6 @@ fn parse_start_line(input: &str) -> Result<StartLine, Vec<u8>> {
|
|||||||
Some(response_body),
|
Some(response_body),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
start_line.version = version.to_string();
|
|
||||||
|
|
||||||
if !StartLine::is_valid_target(target) {
|
if !StartLine::is_valid_target(target) {
|
||||||
return Err(response_builder(
|
return Err(response_builder(
|
||||||
RequestMethods::Head,
|
RequestMethods::Head,
|
||||||
@ -198,6 +186,13 @@ fn parse_start_line(input: &str) -> Result<StartLine, Vec<u8>> {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start_line.method will remain RequestMethods::NULL if it is not supported.
|
||||||
|
match method {
|
||||||
|
"GET" => start_line.method = RequestMethods::Get,
|
||||||
|
"HEAD" => start_line.method = RequestMethods::Head,
|
||||||
|
_ => start_line.method = RequestMethods::Null,
|
||||||
|
}
|
||||||
|
start_line.version = version.to_string();
|
||||||
start_line.target = target.to_string();
|
start_line.target = target.to_string();
|
||||||
|
|
||||||
Ok(start_line)
|
Ok(start_line)
|
||||||
|
Reference in New Issue
Block a user