diff options
-rw-r--r-- | LANGUAGES.md | 2 | ||||
-rw-r--r-- | lib/nodejs/lib/thrift/connection.js | 14 | ||||
-rw-r--r-- | lib/nodejs/lib/thrift/http_connection.js | 23 | ||||
-rw-r--r-- | lib/nodejs/lib/thrift/index.js | 2 | ||||
-rw-r--r-- | lib/nodejs/test/client.js | 18 | ||||
-rw-r--r-- | lib/nodejs/test/server.js | 18 | ||||
-rw-r--r-- | test/known_failures_Linux.json | 9 | ||||
-rw-r--r-- | test/tests.json | 3 |
8 files changed, 69 insertions, 20 deletions
diff --git a/LANGUAGES.md b/LANGUAGES.md index 10b2e153d..779d9b6bb 100644 --- a/LANGUAGES.md +++ b/LANGUAGES.md @@ -234,7 +234,7 @@ The Language/Library Levels indicate the minimum and maximum versions that are u <!-- Since -----------------><td>0.6.0</td> <!-- Build Systems ---------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td> <!-- Language Levels -------><td>6.x</td><td>8.x</td> -<!-- Low-Level Transports --><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td> +<!-- Low-Level Transports --><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td> <!-- Transport Wrappers ----><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td> <!-- Protocols -------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td> <!-- Servers ---------------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td> diff --git a/lib/nodejs/lib/thrift/connection.js b/lib/nodejs/lib/thrift/connection.js index 273339b1f..b54545436 100644 --- a/lib/nodejs/lib/thrift/connection.js +++ b/lib/nodejs/lib/thrift/connection.js @@ -232,7 +232,11 @@ Connection.prototype.connection_gone = function () { return; } - self.connection.connect(self.port, self.host); + if (self.path !== undefined) { + self.connection.connect(self.path); + } else { + self.connection.connect(self.port, self.host); + } self.retry_timer = null; }, this.retry_delay); }; @@ -246,6 +250,14 @@ exports.createConnection = function(host, port, options) { return connection; }; +exports.createUDSConnection = function(path, options) { + var stream = net.createConnection(path); + var connection = new Connection(stream, options); + connection.path = path; + + return connection; +}; + exports.createSSLConnection = function(host, port, options) { if (!('secureProtocol' in options) && !('secureOptions' in options)) { options.secureProtocol = "SSLv23_method"; diff --git a/lib/nodejs/lib/thrift/http_connection.js b/lib/nodejs/lib/thrift/http_connection.js index 508553801..4f5378f43 100644 --- a/lib/nodejs/lib/thrift/http_connection.js +++ b/lib/nodejs/lib/thrift/http_connection.js @@ -59,8 +59,6 @@ var createClient = require('./create_client'); * Initializes a Thrift HttpConnection instance (use createHttpConnection() rather than * instantiating directly). * @constructor - * @param {string} host - The host name or IP to connect to. - * @param {number} port - The TCP port to connect to. * @param {ConnectOptions} options - The configuration options to use. * @throws {error} Exceptions other than InputBufferUnderrunError are rethrown * @event {error} The "error" event is fired when a Node.js error event occurs during @@ -71,15 +69,16 @@ var createClient = require('./create_client'); * semantics implemented over the Node.js http.request() method. * @see {@link createHttpConnection} */ -var HttpConnection = exports.HttpConnection = function(host, port, options) { +var HttpConnection = exports.HttpConnection = function(options) { //Initialize the emitter base object EventEmitter.call(this); //Set configuration var self = this; this.options = options || {}; - this.host = host; - this.port = port; + this.host = this.options.host; + this.port = this.options.port; + this.socketPath = this.options.socketPath; this.https = this.options.https || false; this.transport = this.options.transport || TBufferedTransport; this.protocol = this.options.protocol || TBinaryProtocol; @@ -87,7 +86,8 @@ var HttpConnection = exports.HttpConnection = function(host, port, options) { //Prepare Node.js options this.nodeOptions = { host: this.host, - port: this.port || 80, + port: this.port, + socketPath: this.socketPath, path: this.options.path || '/', method: 'POST', headers: this.options.headers || {}, @@ -238,7 +238,14 @@ HttpConnection.prototype.write = function(data) { * @see {@link ConnectOptions} */ exports.createHttpConnection = function(host, port, options) { - return new HttpConnection(host, port, options); + options.host = host; + options.port = port || 80; + return new HttpConnection(options); +}; + +exports.createHttpUDSConnection = function(path, options) { + options.socketPath = path; + return new HttpConnection(options); }; exports.createHttpClient = createClient @@ -253,4 +260,4 @@ function THTTPException(statusCode, response) { this.type = thrift.TApplicationExceptionType.PROTOCOL_ERROR; this.message = "Received a response with a bad HTTP status code: " + response.statusCode; } -util.inherits(THTTPException, thrift.TApplicationException);
\ No newline at end of file +util.inherits(THTTPException, thrift.TApplicationException); diff --git a/lib/nodejs/lib/thrift/index.js b/lib/nodejs/lib/thrift/index.js index 020726d57..b09953d71 100644 --- a/lib/nodejs/lib/thrift/index.js +++ b/lib/nodejs/lib/thrift/index.js @@ -27,6 +27,7 @@ var connection = require('./connection'); exports.Connection = connection.Connection; exports.createClient = connection.createClient; exports.createConnection = connection.createConnection; +exports.createUDSConnection = connection.createUDSConnection; exports.createSSLConnection = connection.createSSLConnection; exports.createStdIOClient = connection.createStdIOClient; exports.createStdIOConnection = connection.createStdIOConnection; @@ -34,6 +35,7 @@ exports.createStdIOConnection = connection.createStdIOConnection; var httpConnection = require('./http_connection'); exports.HttpConnection = httpConnection.HttpConnection; exports.createHttpConnection = httpConnection.createHttpConnection; +exports.createHttpUDSConnection = httpConnection.createHttpUDSConnection; exports.createHttpClient = httpConnection.createHttpClient; var wsConnection = require('./ws_connection'); diff --git a/lib/nodejs/test/client.js b/lib/nodejs/test/client.js index 006fad2dc..55839f616 100644 --- a/lib/nodejs/test/client.js +++ b/lib/nodejs/test/client.js @@ -36,6 +36,7 @@ program .option('-t, --transport <transport>', 'Set thrift transport (buffered|framed|http) [transport]') .option('--port <port>', 'Set thrift server port number to connect', 9090) .option('--host <host>', 'Set thrift server host to connect', 'localhost') + .option('--domain-socket <path>', 'Set thrift server unix domain socket to connect') .option('--ssl', 'use SSL transport') .option('--promise', 'test with promise style functions') .option('-t, --type <type>', 'Select server type (http|multiplex|tcp|websocket)', 'tcp') @@ -43,6 +44,7 @@ program var host = program.host; var port = program.port; +var domainSocket = program.domainSocket; var type = program.type; var ssl = program.ssl; var promise = program.promise; @@ -83,11 +85,19 @@ var client; var testDriver = promise ? ThriftTestDriverPromise : ThriftTestDriver; if (type === 'tcp' || type === 'multiplex') { - connection = ssl ? - thrift.createSSLConnection(host, port, options) : - thrift.createConnection(host, port, options); + if (domainSocket) { + connection = thrift.createUDSConnection(domainSocket, options); + } else { + connection = ssl ? + thrift.createSSLConnection(host, port, options) : + thrift.createConnection(host, port, options); + } } else if (type === 'http') { - connection = thrift.createHttpConnection(host, port, options); + if (domainSocket) { + connection = thrift.createHttpUDSConnection(domainSocket, options); + } else { + connection = thrift.createHttpConnection(host, port, options); + } } else if (type === 'websocket') { connection = thrift.createWSConnection(host, port, options); connection.open(); diff --git a/lib/nodejs/test/server.js b/lib/nodejs/test/server.js index 8f2e06b8d..030d28b38 100644 --- a/lib/nodejs/test/server.js +++ b/lib/nodejs/test/server.js @@ -36,11 +36,13 @@ program .option('-t, --transport <transport>', 'Set thrift transport (buffered|framed|http)', 'buffered') .option('--ssl', 'use ssl transport') .option('--port <port>', 'Set thrift server port', 9090) + .option('--domain-socket <path>', 'Set thift server unix domain socket') .option('--promise', 'test with promise style functions') .option('-t, --type <type>', 'Select server type (http|multiplex|tcp|websocket)', 'tcp') .parse(process.argv); var port = program.port; +var domainSocket = program.domainSocket; var type = program.type; var ssl = program.ssl; var promise = program.promise; @@ -88,10 +90,12 @@ if (type === 'multiplex') { } if (ssl) { - options.tls = { - key: fs.readFileSync(path.resolve(__dirname, 'server.key')), - cert: fs.readFileSync(path.resolve(__dirname, 'server.crt')) - }; + if (type === 'tcp' || type === 'multiplex' || type === 'http' || type === 'websocket') { + options.tls = { + key: fs.readFileSync(path.resolve(__dirname, 'server.key')), + cert: fs.readFileSync(path.resolve(__dirname, 'server.crt')) + }; + } } var server; @@ -103,4 +107,8 @@ if (type === 'tcp') { server = thrift.createWebServer(options); } -server.listen(port); +if (domainSocket) { + server.listen(domainSocket); +} else if (type === 'tcp' || type === 'multiplex' || type === 'http' || type === 'websocket') { + server.listen(port); +} diff --git a/test/known_failures_Linux.json b/test/known_failures_Linux.json index a88609824..16a912dd0 100644 --- a/test/known_failures_Linux.json +++ b/test/known_failures_Linux.json @@ -67,16 +67,22 @@ "cpp-java_multij_http-ip-ssl", "cpp-nodejs_binary_http-ip", "cpp-nodejs_binary_http-ip-ssl", + "cpp-nodejs_binary_http-domain", "cpp-nodejs_compact_http-ip", "cpp-nodejs_compact_http-ip-ssl", + "cpp-nodejs_compact_http-domain", "cpp-nodejs_json_http-ip", "cpp-nodejs_json_http-ip-ssl", + "cpp-nodejs_json_http-domain", "cpp-nodejs_multi-binary_http-ip", "cpp-nodejs_multi-binary_http-ip-ssl", + "cpp-nodejs_multi-binary_http-domain", "cpp-nodejs_multic-compact_http-ip", "cpp-nodejs_multic-compact_http-ip-ssl", + "cpp-nodejs_multic-compact_http-domain", "cpp-nodejs_multij-json_http-ip", "cpp-nodejs_multij-json_http-ip-ssl", + "cpp-nodejs_multij-json_http-domain", "cpp-rs_multi_buffered-ip", "cpp-rs_multi_framed-ip", "cpp-rs_multic_buffered-ip", @@ -235,10 +241,13 @@ "netcore-csharp_json_framed-ip-ssl", "nodejs-cpp_binary_http-ip", "nodejs-cpp_binary_http-ip-ssl", + "nodejs-cpp_binary_http-domain", "nodejs-cpp_compact_http-ip", "nodejs-cpp_compact_http-ip-ssl", + "nodejs-cpp_compact_http-domain", "nodejs-cpp_json_http-ip", "nodejs-cpp_json_http-ip-ssl", + "nodejs-cpp_json_http-domain", "nodejs-d_binary_http-ip", "nodejs-d_binary_http-ip-ssl", "nodejs-d_compact_http-ip", diff --git a/test/tests.json b/test/tests.json index 99050a15e..511be5f47 100644 --- a/test/tests.json +++ b/test/tests.json @@ -192,7 +192,8 @@ ], "sockets": [ "ip", - "ip-ssl" + "ip-ssl", + "domain" ], "protocols": [ "compact", |