You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by mj...@apache.org on 2017/11/19 22:26:41 UTC

[1/2] incubator-guacamole-client git commit: GUACAMOLE-437: Custom headers for Guacamole tunnel

Repository: incubator-guacamole-client
Updated Branches:
  refs/heads/master e2c8594b3 -> ff2bd3d4f


GUACAMOLE-437: Custom headers for Guacamole tunnel


Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/948b4e80
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/948b4e80
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/948b4e80

Branch: refs/heads/master
Commit: 948b4e804cd58bcaf1f2f01914ef1f90950f43e6
Parents: e2c8594
Author: Ignasi Barrera <na...@apache.org>
Authored: Thu Nov 16 13:03:17 2017 +0100
Committer: Ignasi Barrera <na...@apache.org>
Committed: Sun Nov 19 03:45:39 2017 +0100

----------------------------------------------------------------------
 .../src/main/webapp/modules/Tunnel.js           | 34 +++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/948b4e80/guacamole-common-js/src/main/webapp/modules/Tunnel.js
----------------------------------------------------------------------
diff --git a/guacamole-common-js/src/main/webapp/modules/Tunnel.js b/guacamole-common-js/src/main/webapp/modules/Tunnel.js
index 2b1826d..a4e399d 100644
--- a/guacamole-common-js/src/main/webapp/modules/Tunnel.js
+++ b/guacamole-common-js/src/main/webapp/modules/Tunnel.js
@@ -182,8 +182,13 @@ Guacamole.Tunnel.State = {
  *     Whether tunnel requests will be cross-domain, and thus must use CORS
  *     mechanisms and headers. By default, it is assumed that tunnel requests
  *     will be made to the same domain.
+ *
+ * @param {Object} [extraTunnelHeaders={}]
+ *     Key value pairs containing the header names and values of any additional
+ *     headers to be sent in tunnel requests. By default, no extra headers will
+ *     be added.
  */
-Guacamole.HTTPTunnel = function(tunnelURL, crossDomain) {
+Guacamole.HTTPTunnel = function(tunnelURL, crossDomain, extraTunnelHeaders) {
 
     /**
      * Reference to this HTTP tunnel.
@@ -215,6 +220,29 @@ Guacamole.HTTPTunnel = function(tunnelURL, crossDomain) {
     var receive_timeout = null;
 
     /**
+     * Additional headers to be sent in tunnel requests. This dictionary can be
+     * populated with key/value header pairs to pass information such as authentication
+     * tokens, etc.
+     *
+     * @private
+     */
+    var extraHeaders = extraTunnelHeaders || {}
+
+    /**
+     * Adds the configured additional headers to the given request.
+     *
+     * @params {XMLHttpRequest} request
+     *     The request where the configured extra headers will be added.
+     *
+     * @private
+     */
+    function addExtraHeaders(request) {
+        for (var name in tunnel.extraHeaders) {
+            request.setRequestHeader(name, tunnel.extraHeaders[name]);
+        }
+    }
+
+    /**
      * Initiates a timeout which, if data is not received, causes the tunnel
      * to close with an error.
      * 
@@ -322,6 +350,7 @@ Guacamole.HTTPTunnel = function(tunnelURL, crossDomain) {
             var message_xmlhttprequest = new XMLHttpRequest();
             message_xmlhttprequest.open("POST", TUNNEL_WRITE + tunnel.uuid);
             message_xmlhttprequest.withCredentials = withCredentials;
+            addExtraHeaders(message_xmlhttprequest);
             message_xmlhttprequest.setRequestHeader("Content-type", "application/octet-stream");
 
             // Once response received, send next queued event.
@@ -553,6 +582,7 @@ Guacamole.HTTPTunnel = function(tunnelURL, crossDomain) {
         var xmlhttprequest = new XMLHttpRequest();
         xmlhttprequest.open("GET", TUNNEL_READ + tunnel.uuid + ":" + (request_id++));
         xmlhttprequest.withCredentials = withCredentials;
+        addExtraHeaders(xmlhttprequest);
         xmlhttprequest.send(null);
 
         return xmlhttprequest;
@@ -595,6 +625,7 @@ Guacamole.HTTPTunnel = function(tunnelURL, crossDomain) {
 
         connect_xmlhttprequest.open("POST", TUNNEL_CONNECT, true);
         connect_xmlhttprequest.withCredentials = withCredentials;
+        addExtraHeaders(connect_xmlhttprequest);
         connect_xmlhttprequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
         connect_xmlhttprequest.send(data);
 
@@ -1137,6 +1168,7 @@ Guacamole.StaticHTTPTunnel = function StaticHTTPTunnel(url, crossDomain) {
         xhr = new XMLHttpRequest();
         xhr.open('GET', url);
         xhr.withCredentials = !!crossDomain;
+        addExtraHeaders(xhr);
         xhr.responseType = 'text';
         xhr.send(null);
 


[2/2] incubator-guacamole-client git commit: GUACAMOLE-437: Merge support for including custom headers within HTTP tunnel requests.

Posted by mj...@apache.org.
GUACAMOLE-437: Merge support for including custom headers within HTTP tunnel requests.


Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/ff2bd3d4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/ff2bd3d4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/ff2bd3d4

Branch: refs/heads/master
Commit: ff2bd3d4f8c24dda68ada899ea52288cb432e15d
Parents: e2c8594 948b4e8
Author: Michael Jumper <mj...@apache.org>
Authored: Sun Nov 19 14:25:17 2017 -0800
Committer: Michael Jumper <mj...@apache.org>
Committed: Sun Nov 19 14:25:17 2017 -0800

----------------------------------------------------------------------
 .../src/main/webapp/modules/Tunnel.js           | 34 +++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)
----------------------------------------------------------------------