From: Mark Donnelly Date: Mon, 24 Nov 2014 21:07:15 +0000 (-0500) Subject: Use location.hostname as part of the name of the other end; reorder calls for debugga... X-Git-Url: http://www.project-moonshot.org/gitweb/?p=gssweb.git;a=commitdiff_plain;h=03b2a875b8b4a5c2463d4a895559e24aa7feb837 Use location.hostname as part of the name of the other end; reorder calls for debuggability. The location.host includes the port number in the URL, if specified; the hostname does not. The reordering of calls makes it easier to tell whether the crash is happening during a 200/Success or 401/Unauthorized response. --- diff --git a/navigator.gssweb.js b/navigator.gssweb.js index 0ff0f13..3027f97 100644 --- a/navigator.gssweb.js +++ b/navigator.gssweb.js @@ -68,7 +68,7 @@ var GSSWeb = (function () { GSSWeb.prototype.authGetServerName = function () { this.gss.import_name({ - name: "HTTP@" + window.location.host, + name: "HTTP@" + window.location.hostname, success: this.authReceiveServerName.bind(this) }); }; @@ -153,11 +153,10 @@ var GSSWeb = (function () { return; } - var serverResponse = JSON.parse(this.xhr.responseText); - this.serverToken = serverResponse.gssweb.token; switch (this.xhr.status) { case 200: // Finished! + var serverResponse = JSON.parse(this.xhr.responseText); var decoded = window.atob(serverResponse.application.data); this.authenticationState = true; this.success( @@ -168,12 +167,14 @@ var GSSWeb = (function () { break; case 401: // Continue needed + var serverResponse = JSON.parse(this.xhr.responseText); + this.serverToken = serverResponse.gssweb.token; this.authInitSecContext(); break; default: // We have some server-reported error this.error( - window.location.host + + window.location.hostname + " reported an error; aborting", this.appTag );