From d853f96cf1ecb3815028cd98b78e1d9236cd3e1a Mon Sep 17 00:00:00 2001 From: Igor Elpin Date: Mon, 28 Nov 2022 14:21:37 +0300 Subject: [PATCH] up gitignore --- .gitignore | 2 +- .idea/rust.iml | 2 ++ first-app-00/src/main.rs | 3 --- {first-app-00 => simple}/Cargo.lock | 2 +- {first-app-00 => simple}/Cargo.toml | 2 +- simple/src/main.rs | 24 ++++++++++++++++++++++++ 6 files changed, 29 insertions(+), 6 deletions(-) delete mode 100644 first-app-00/src/main.rs rename {first-app-00 => simple}/Cargo.lock (85%) rename {first-app-00 => simple}/Cargo.toml (87%) create mode 100644 simple/src/main.rs diff --git a/.gitignore b/.gitignore index 9fef353..36d98a7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ # Default ignored files /shelf/ /.idea/workspace.xml -target/* +*/target/ diff --git a/.idea/rust.iml b/.idea/rust.iml index 6d0ab83..7093ab5 100644 --- a/.idea/rust.iml +++ b/.idea/rust.iml @@ -4,7 +4,9 @@ + + diff --git a/first-app-00/src/main.rs b/first-app-00/src/main.rs deleted file mode 100644 index e7a11a9..0000000 --- a/first-app-00/src/main.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - println!("Hello, world!"); -} diff --git a/first-app-00/Cargo.lock b/simple/Cargo.lock similarity index 85% rename from first-app-00/Cargo.lock rename to simple/Cargo.lock index 1a75e76..05a9e70 100644 --- a/first-app-00/Cargo.lock +++ b/simple/Cargo.lock @@ -3,5 +3,5 @@ version = 3 [[package]] -name = "first-app-00" +name = "simple" version = "0.1.0" diff --git a/first-app-00/Cargo.toml b/simple/Cargo.toml similarity index 87% rename from first-app-00/Cargo.toml rename to simple/Cargo.toml index 7fe4405..c8cb603 100644 --- a/first-app-00/Cargo.toml +++ b/simple/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "first-app-00" +name = "simple" version = "0.1.0" edition = "2021" diff --git a/simple/src/main.rs b/simple/src/main.rs new file mode 100644 index 0000000..63518b4 --- /dev/null +++ b/simple/src/main.rs @@ -0,0 +1,24 @@ +use std:: { + io::{ prelude::*,BufReader}, + net::{TcpListener,TcpStream}, +}; + + +fn main() { + let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); + + for stream in listener.incoming() { + let stream= stream.unwrap(); + handle_connect(stream) + } +} + +fn handle_connect(mut stream: TcpStream) { + let buf_reader = BufReader::new(&mut stream); + let http_request: Vec<_> = buf_reader + .lines() + .map(|result|result.unwrap()) + .take_while(|line|!line.is_empty()) + .collect(); + println!("Request: {:#?}",http_request); +} \ No newline at end of file