Fix default websocket port detection in spice_auto.html

If server runs on port 80 or 443 the default value of
window.location.port is an empty string

Signed-off-by: Jordan Pittier <jordan.pittier-ext@cloudwatt.com>
This commit is contained in:
Jordan Pittier 2013-08-20 19:04:36 +02:00 committed by Jeremy White
parent 96e6383995
commit b0509ca449

View File

@ -85,7 +85,20 @@
// By default, use the host and port of server that served this file
host = spice_query_var('host', window.location.hostname);
port = spice_query_var('port', window.location.port);
// Note that using the web server port only makes sense
// if your web server has a reverse proxy to relay the WebSocket
// traffic to the correct destination port.
var default_port = window.location.port;
if (!default_port) {
if (window.location.protocol == 'http:') {
default_port = 80;
}
else if (window.location.protocol == 'https:') {
default_port = 443;
}
}
port = spice_query_var('port', default_port);
// If a token variable is passed in, set the parameter in a cookie.
// This is used by nova-spiceproxy.