diff --git a/lib/js/src/thrift.js b/lib/js/src/thrift.js
index <HASH>..<HASH> 100644
--- a/lib/js/src/thrift.js
+++ b/lib/js/src/thrift.js
@@ -310,6 +310,7 @@ Thrift.Transport = Thrift.TXHRTransport = function(url, options) {
     this.wpos = 0;
     this.rpos = 0;
     this.useCORS = (options && options.useCORS);
+    this.customHeaders = options ? (options.customHeaders ? options.customHeaders : {}): {};
     this.send_buf = '';
     this.recv_buf = '';
 };
@@ -376,6 +377,11 @@ Thrift.TXHRTransport.prototype = {
 
         xreq.open('POST', this.url, !!async);
 
+        // add custom headers
+        Object.keys(self.customHeaders).forEach(function(prop) {
+            xreq.setRequestHeader(prop, self.customHeaders[prop]);
+        });
+
         if (xreq.setRequestHeader) {
             xreq.setRequestHeader('Accept', 'application/vnd.apache.thrift.json; charset=utf-8');
             xreq.setRequestHeader('Content-Type', 'application/vnd.apache.thrift.json; charset=utf-8');
THRIFT-<I>: Add HTTP header support to JavaScript lib
Client: JavaScript lib
Patch: David Sautter

Adds a customHeaders field to the XHR transport options
supporting multiple key-value custom HTTP headers to pass
with the request.