@@ -332,7 +332,7 @@ fn handle_net_error(e: NetError, msg: &str) -> io::Error {
332
332
}
333
333
334
334
/// Send an HTTP request to the given host:port. Returns the decoded response.
335
- /// Interanlly , this creates a socket, connects it, sends the HTTP request, and decodes the HTTP
335
+ /// Internally , this creates a socket, connects it, sends the HTTP request, and decodes the HTTP
336
336
/// response. It is a blocking operation.
337
337
///
338
338
/// If the request encounters a network error, then return an error. Don't retry.
@@ -425,7 +425,7 @@ pub fn send_request(
425
425
} ) ?;
426
426
427
427
// Step 3: load up the request with the message we're gonna send, and iteratively dump its
428
- // bytes from the handle into the socket (the connection does internall buffering and
428
+ // bytes from the handle into the socket (the connection does internal buffering and
429
429
// bookkeeping to deal with the cases where we fail to fill the socket buffer, or we can't send
430
430
// anymore because the socket buffer is currently full).
431
431
request
@@ -480,7 +480,7 @@ pub fn send_request(
480
480
debug ! ( "send_request(receiving data): drain inbox" ) ;
481
481
connection. drain_inbox ( ) ;
482
482
483
- // see of we got a message that was fulfilled in our handle
483
+ // see if we got a message that was fulfilled in our handle
484
484
debug ! ( "send_request(receiving data): try receive response" ) ;
485
485
let rh = match request_handle. try_recv ( ) {
486
486
Ok ( resp) => {
@@ -1928,15 +1928,14 @@ mod test {
1928
1928
}
1929
1929
}
1930
1930
1931
- fn start_mock_server ( response : & str , client_done_signal : Receiver < ( ) > ) -> String {
1931
+ fn start_mock_server ( response : String , client_done_signal : Receiver < ( ) > ) -> String {
1932
1932
// Bind to an available port on localhost
1933
1933
let listener = TcpListener :: bind ( "127.0.0.1:0" ) . expect ( "Failed to bind server" ) ;
1934
1934
let addr = listener. local_addr ( ) . unwrap ( ) ;
1935
1935
1936
1936
debug ! ( "Mock server listening on {}" , addr) ;
1937
1937
1938
1938
// Start the server in a new thread
1939
- let response = response. to_string ( ) ;
1940
1939
thread:: spawn ( move || {
1941
1940
for stream in listener. incoming ( ) {
1942
1941
debug ! ( "Mock server accepted connection" ) ;
@@ -1993,13 +1992,12 @@ mod test {
1993
1992
1994
1993
// Create a channel to signal when the client is done reading
1995
1994
let ( tx_client_done, rx_client_done) = channel ( ) ;
1996
- let server_addr = start_mock_server ( mock_response, rx_client_done) ;
1995
+ let server_addr = start_mock_server ( mock_response. to_string ( ) , rx_client_done) ;
1997
1996
let timeout_duration = Duration :: from_secs ( 5 ) ;
1998
1997
1999
- let host = server_addr. split ( ':' ) . collect :: < Vec < & str > > ( ) [ 0 ] ; // Host part
2000
- let port = server_addr. split ( ':' ) . collect :: < Vec < & str > > ( ) [ 1 ]
2001
- . parse ( )
2002
- . unwrap ( ) ; // Port part
1998
+ let parts = server_addr. split ( ':' ) . collect :: < Vec < & str > > ( ) ;
1999
+ let host = parts[ 0 ] ;
2000
+ let port = parts[ 1 ] . parse ( ) . unwrap ( ) ;
2003
2001
2004
2002
// Attempt to send a request to the mock server
2005
2003
let result = send_request (
0 commit comments