Merge pull request #359 from mtbc/allow-IPv6-SocketAddr

remove [] enclosing IPv6 host address
This commit is contained in:
Daniel Abramov 2023-06-10 11:25:25 +02:00 committed by GitHub
commit d7b559d724
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 0 deletions

View File

@ -54,6 +54,7 @@ pub fn connect_with_config<Req: IntoClientRequest>(
let uri = request.uri();
let mode = uri_mode(uri)?;
let host = request.uri().host().ok_or(Error::Url(UrlError::NoHostName))?;
let host = if host.starts_with('[') { &host[1..host.len() - 1] } else { host };
let port = uri.port_u16().unwrap_or(match mode {
Mode::Plain => 80,
Mode::Tls => 443,