File tree 2 files changed +3
-3
lines changed
2 files changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ fn read_request_line(req: &mut TcpStream) -> io::Result<String> {
14
14
let mut line_buf = Vec :: < u8 > :: new ( ) ;
15
15
loop {
16
16
let mut ch_buf = vec ! [ 0u8 ] ;
17
- req. read ( & mut ch_buf) ?;
17
+ req. read_exact ( & mut ch_buf) ?;
18
18
if let Some ( '\n' ) = ch_buf. first ( ) . map ( |b| char:: from ( * b) ) {
19
19
break ;
20
20
} else {
@@ -25,7 +25,7 @@ fn read_request_line(req: &mut TcpStream) -> io::Result<String> {
25
25
}
26
26
27
27
fn handle_http_request ( req : & str , res : TcpStream ) -> io:: Result < ( ) > {
28
- if let & [ "GET" , "/" , ..] = req. split_whitespace ( ) . collect :: < Vec < _ > > ( ) . as_slice ( ) {
28
+ if let [ "GET" , "/" , ..] = req. split_whitespace ( ) . collect :: < Vec < _ > > ( ) . as_slice ( ) {
29
29
get_root ( res) ?;
30
30
} else {
31
31
eprintln ! ( "cannot accept the following request: {}" , req) ;
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ impl<R: Read + BufRead> ReadResponse<R> {
49
49
fn main ( ) {
50
50
let mut conn = TcpStream :: connect ( "example.com:80" ) . unwrap ( ) ;
51
51
52
- conn. write ( "GET / HTTP/1.0\r \n Host: example.com\r \n \r \n " . as_bytes ( ) )
52
+ conn. write_all ( "GET / HTTP/1.0\r \n Host: example.com\r \n \r \n " . as_bytes ( ) )
53
53
. unwrap ( ) ;
54
54
let mut buf_reader = BufReader :: new ( conn) ;
55
55
let mut res = ReadResponse :: new ( & mut buf_reader) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments