File tree 1 file changed +10
-19
lines changed
1 file changed +10
-19
lines changed Original file line number Diff line number Diff line change 1
- use std:: io:: Write ;
2
- use std:: process:: { Command , Stdio } ;
1
+ use std:: process:: Command ;
3
2
use std:: thread;
4
3
use std:: time;
5
4
@@ -22,24 +21,16 @@ fn server() {
22
21
23
22
thread:: sleep ( time:: Duration :: from_secs ( 1 ) ) ;
24
23
25
- let mut cli = Command :: new ( "openssl" )
26
- . arg ( "s_client" )
27
- . arg ( "-ign_eof" )
28
- . arg ( "-connect" )
29
- . arg ( "localhost:1337" )
30
- . stdin ( Stdio :: piped ( ) )
31
- . spawn ( )
32
- . expect ( "cannot run openssl" ) ;
33
-
34
- cli. stdin
35
- . as_mut ( )
36
- . unwrap ( )
37
- . write ( b"GET / HTTP/1.0\r \n \r \n " )
38
- . unwrap ( ) ;
39
-
40
- let rc = cli. wait ( ) . expect ( "openssl failed" ) ;
24
+ let output = Command :: new ( "curl" )
25
+ . arg ( "--insecure" )
26
+ . arg ( "--http1.0" )
27
+ . arg ( "--silent" )
28
+ . arg ( "https://localhost:1337" )
29
+ . output ( )
30
+ . expect ( "cannot run curl" ) ;
41
31
42
- assert ! ( rc. success( ) ) ;
32
+ println ! ( "client output: {:?}" , output. stdout) ;
33
+ assert_eq ! ( output. stdout, b"Try POST /echo\n " ) ;
43
34
44
35
srv. kill ( ) . unwrap ( ) ;
45
36
}
You can’t perform that action at this time.
0 commit comments