File tree Expand file tree Collapse file tree 1 file changed +10
-19
lines changed Expand file tree Collapse file tree 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 ; 
32use  std:: thread; 
43use  std:: time; 
54
@@ -22,24 +21,16 @@ fn server() {
2221
2322    thread:: sleep ( time:: Duration :: from_secs ( 1 ) ) ; 
2423
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" ) ; 
4131
42-     assert ! ( rc. success( ) ) ; 
32+     println ! ( "client output: {:?}" ,  output. stdout) ; 
33+     assert_eq ! ( output. stdout,  b"Try POST /echo\n " ) ; 
4334
4435    srv. kill ( ) . unwrap ( ) ; 
4536} 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments