in http-common/src/connector.rs [338:375]
fn to_url(&self) -> Result<url::Url, String> {
match self {
Connector::Tcp { host, port } => {
let url = format!("http://{host}:{port}");
let mut url: url::Url = url.parse().expect("hard-coded URL parses successfully");
url.set_host(Some(host))
.map_err(|err| format!("could not set host {host:?}: {err:?}"))?;
if *port != 80 {
url.set_port(Some(*port))
.map_err(|()| format!("could not set port {port:?}"))?;
}
Ok(url)
}
Connector::Unix { socket_path } => {
let socket_path = socket_path.to_str().ok_or_else(|| {
format!(
"socket path {} cannot be serialized as a utf-8 string",
socket_path.display()
)
})?;
let mut url: url::Url = "unix:///unix-socket"
.parse()
.expect("hard-coded URL parses successfully");
url.set_path(socket_path);
Ok(url)
}
Connector::Fd { fd } => {
let fd_path = format!("fd://{fd}");
let url = url::Url::parse(&fd_path).expect("hard-coded URL parses successfully");
Ok(url)
}
}
}