ws: obtain port when not specified (#5922)

pull/5924/head
Carlos Esquerdo Bernat 2020-07-22 16:35:30 +02:00 committed by GitHub
parent 0d8ebf5845
commit 635c99e2ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -107,10 +107,19 @@ fn (ws &Client) parse_uri() &Uri {
panic(err)
}
v := u.request_uri().split('?')
mut port := u.port()
//Check if port is empty and check protocol to get the port, secure by default
if port == '' {
if ws.uri.contains('://') {
port = if ws.uri.split('://')[0] == 'ws' { '80' } else { '443' }
} else {
port = '443'
}
}
querystring := if v.len > 1 { '?' + v[1] } else { '' }
return &Uri{
hostname: u.hostname()
port: u.port()
port: port
resource: v[0]
querystring: querystring
}