advance-practice1/web-server #1155
Replies: 3 comments 13 replies
-
问个问题 |
Beta Was this translation helpful? Give feedback.
8 replies
-
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_connection(stream);
}
}
fn handle_connection(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);
} stream不是不可变的吗,怎么能当成可变传入函数里面 |
Beta Was this translation helpful? Give feedback.
5 replies
-
请教个问题: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
advance-practice1/web-server
https://course.rs/advance-practice1/web-server.html
Beta Was this translation helpful? Give feedback.
All reactions