Support multiple mime types

Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/c7652cc6
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/c7652cc6
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/c7652cc6

Branch: refs/heads/TINKERPOP-1489
Commit: c7652cc62d7d5004c3391fc971d56798331734f6
Parents: 0b9c1b8
Author: Jorge Bay Gondra <jorgebaygon...@gmail.com>
Authored: Wed Nov 29 12:02:50 2017 +0100
Committer: Jorge Bay Gondra <jorgebaygon...@gmail.com>
Committed: Mon Jan 8 11:30:48 2018 +0100

----------------------------------------------------------------------
 .../lib/driver/driver-remote-connection.js           | 15 +++++++++------
 .../lib/driver/remote-connection.js                  |  2 +-
 2 files changed, 10 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c7652cc6/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
----------------------------------------------------------------------
diff --git 
a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
 
b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
index 31f27cd..51661c3 100644
--- 
a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
+++ 
b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
@@ -29,8 +29,7 @@ var RemoteConnection = 
require('./remote-connection').RemoteConnection;
 var utils = require('../utils');
 var serializer = require('../structure/io/graph-serializer');
 var inherits = utils.inherits;
-var mimeType = 'application/vnd.gremlin-v2.0+json';
-var header = String.fromCharCode(mimeType.length) + mimeType;
+var defaultMimeType = 'application/vnd.gremlin-v2.0+json';
 var responseStatusCode = {
   success: 200,
   noContent: 204,
@@ -41,16 +40,18 @@ var responseStatusCode = {
  * Creates a new instance of DriverRemoteConnection.
  * @param {String} url The resource uri.
  * @param {Object} [options] The connection options.
- * @param {String} [options.traversalSource] The traversal source. Defaults 
to: 'g'.
  * @param {Array} [options.ca] Trusted certificates.
  * @param {String|Array|Buffer} [options.cert] The certificate key.
+ * @param {String} [options.mimeType] The mime type to use.
  * @param {String|Buffer} [options.pfx] The private key, certificate, and CA 
certs.
- * @param {GraphSONReader} [options.reader] The GraphSON2 reader to use.
+ * @param {GraphSONReader} [options.reader] The reader to use.
  * @param {Boolean} [options.rejectUnauthorized] Determines whether to verify 
or not the server certificate.
- * @param {GraphSONWriter} [options.writer] The GraphSON2 writer to use.
+ * @param {String} [options.traversalSource] The traversal source. Defaults 
to: 'g'.
+ * @param {GraphSONWriter} [options.writer] The writer to use.
  * @constructor
  */
 function DriverRemoteConnection(url, options) {
+  RemoteConnection.call(this, url);
   options = options || {};
   this._ws = new WebSocket(url, {
     ca: options.ca,
@@ -75,6 +76,8 @@ function DriverRemoteConnection(url, options) {
   this._openPromise = null;
   this._openCallback = null;
   this._closePromise = null;
+  var mimeType = options.mimeType || defaultMimeType;
+  this._header = String.fromCharCode(mimeType.length) + mimeType;
   this.isOpen = false;
   this.traversalSource = options.traversalSource || 'g';
 }
@@ -114,7 +117,7 @@ DriverRemoteConnection.prototype.submit = function 
(bytecode, promiseFactory) {
         callback: callback,
         result: null
       };
-      var message = bufferFromString(header + 
JSON.stringify(self._getRequest(requestId, bytecode)));
+      var message = bufferFromString(self._header + 
JSON.stringify(self._getRequest(requestId, bytecode)));
       self._ws.send(message);
     });
   });

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c7652cc6/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
----------------------------------------------------------------------
diff --git 
a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
 
b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
index 8176c37..235375a 100644
--- 
a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
+++ 
b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
@@ -27,7 +27,7 @@ var TraversalStrategy = 
require('../process/traversal-strategy').TraversalStrate
 var utils = require('../utils');
 var inherits = utils.inherits;
 
-function RemoteConnection(url, traversalSource) {
+function RemoteConnection(url) {
   this.url = url;
 }
 

Reply via email to