Parse Path from HTTP request
Change-Id: Ic85c10705e787b6a152d316ca83fe88277a27328
Reviewed-on: https://git.clicks.codes/c/Clicks/BYO/HttpServer/rust/+/248
Tested-by: Skyler Grey <minion@clicks.codes>
Reviewed-by: Skyler Grey <minion@clicks.codes>
Reviewed-by: Samuel Shuert <coded@clicks.codes>
diff --git a/src/main.rs b/src/main.rs
index e78f067..1b23148 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -8,16 +8,11 @@
Ok(mut _stream) => {
println!("accepted new connection");
- let mut buf: String = Default::default();
+ let mut buf: [u8; 6] = [0; 6];
- _stream.read_to_string(&mut buf).unwrap();
+ _stream.read_exact(&mut buf).unwrap();
- let mut parts = buf.split(" ");
-
- let _method = parts.next().unwrap();
- let path = parts.next().unwrap();
-
- let status = if path == "/" {
+ let status = if buf[5] == b' ' {
"200 OK"
} else {
"404 Not Found"