Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 1164415

Browse files
committed
Bug 1857193 - Make passing --port=0 select a free port, r=webdriver-reviewers,jdescottes
Previously this bound to a free port, but we weren't allowing connections because we checked the Host header against the specified port (i.e. 0) rather than the bound port. Differential Revision: https://phabricator.services.mozilla.com/D189925
1 parent 15b53f5 commit 1164415

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

testing/webdriver/src/server.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ impl Drop for Listener {
203203
}
204204

205205
pub fn start<T, U>(
206-
address: SocketAddr,
206+
mut address: SocketAddr,
207207
allow_hosts: Vec<Host>,
208208
allow_origins: Vec<Url>,
209209
handler: T,
@@ -216,6 +216,11 @@ where
216216
let listener = StdTcpListener::bind(address)?;
217217
listener.set_nonblocking(true)?;
218218
let addr = listener.local_addr()?;
219+
if address.port() == 0 {
220+
// If we passed in 0 as the port number the OS will assign an unused port;
221+
// we want to update the address to the actual used port
222+
address.set_port(addr.port())
223+
}
219224
let (msg_send, msg_recv) = channel();
220225

221226
let builder = thread::Builder::new().name("webdriver server".to_string());

0 commit comments

Comments
 (0)