mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-08 14:11:21 +00:00
GUAC-558: Use same error handling function throughout HTTP tunnel. Ignore RESOURCE_NOT_FOUND for connected HTTP tunnels as that actually signals end-of-stream.
This commit is contained in:
@@ -169,9 +169,16 @@ Guacamole.HTTPTunnel = function(tunnelURL) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// If connection closed abnormally, signal error.
|
// If connection closed abnormally, signal error.
|
||||||
if (status.code !== Guacamole.Status.Code.SUCCESS && tunnel.onerror)
|
if (status.code !== Guacamole.Status.Code.SUCCESS && tunnel.onerror) {
|
||||||
|
|
||||||
|
// Ignore RESOURCE_NOT_FOUND if we've already connected, as that
|
||||||
|
// only signals end-of-stream for the HTTP tunnel.
|
||||||
|
if (tunnel.state === Guacamole.Tunnel.State.CONNECTING
|
||||||
|
|| status.code !== Guacamole.Status.Code.RESOURCE_NOT_FOUND)
|
||||||
tunnel.onerror(status);
|
tunnel.onerror(status);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Mark as closed
|
// Mark as closed
|
||||||
tunnel.state = Guacamole.Tunnel.State.CLOSED;
|
tunnel.state = Guacamole.Tunnel.State.CLOSED;
|
||||||
if (tunnel.onstatechange)
|
if (tunnel.onstatechange)
|
||||||
@@ -260,25 +267,12 @@ Guacamole.HTTPTunnel = function(tunnelURL) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getHTTPTunnelErrorStatus(xmlhttprequest) {
|
function handleHTTPTunnelError(xmlhttprequest) {
|
||||||
|
|
||||||
var code = parseInt(xmlhttprequest.getResponseHeader("Guacamole-Status-Code"));
|
var code = parseInt(xmlhttprequest.getResponseHeader("Guacamole-Status-Code"));
|
||||||
var message = xmlhttprequest.getResponseHeader("Guacamole-Error-Message");
|
var message = xmlhttprequest.getResponseHeader("Guacamole-Error-Message");
|
||||||
|
|
||||||
return new Guacamole.Status(code, message);
|
close_tunnel(new Guacamole.Status(code, message));
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleHTTPTunnelError(xmlhttprequest) {
|
|
||||||
|
|
||||||
// Get error status
|
|
||||||
var status = getHTTPTunnelErrorStatus(xmlhttprequest);
|
|
||||||
|
|
||||||
// Call error handler
|
|
||||||
if (tunnel.onerror) tunnel.onerror(status);
|
|
||||||
|
|
||||||
// Finish
|
|
||||||
tunnel.disconnect();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -492,8 +486,7 @@ Guacamole.HTTPTunnel = function(tunnelURL) {
|
|||||||
|
|
||||||
// If failure, throw error
|
// If failure, throw error
|
||||||
if (connect_xmlhttprequest.status !== 200) {
|
if (connect_xmlhttprequest.status !== 200) {
|
||||||
var status = getHTTPTunnelErrorStatus(connect_xmlhttprequest);
|
handleHTTPTunnelError(connect_xmlhttprequest);
|
||||||
close_tunnel(status);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user