From 0fd7795ace9ace5a65489a3dbd99cf0aa8139ddc Mon Sep 17 00:00:00 2001 From: AustrianToast Date: Sun, 23 Mar 2025 20:09:39 +0100 Subject: [PATCH] reorder code --- src/main.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/main.rs b/src/main.rs index efe71b8..55cf10e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -150,14 +150,6 @@ fn parse_start_line(input: &str) -> Result> { 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) { return Err(response_builder( RequestMethods::Head, @@ -166,7 +158,6 @@ fn parse_start_line(input: &str) -> Result> { None, )); } - if version != "HTTP/1.1" && version != "HTTP/1.0" { "Server only supports major version 1 of HTTP" .as_bytes() @@ -186,9 +177,6 @@ fn parse_start_line(input: &str) -> Result> { Some(response_body), )); } - - start_line.version = version.to_string(); - if !StartLine::is_valid_target(target) { return Err(response_builder( RequestMethods::Head, @@ -198,6 +186,13 @@ fn parse_start_line(input: &str) -> Result> { )); } + // 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(); Ok(start_line)