Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/clickhouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var JSONStream = require ('./streams').JSONStream;

var parseError = require ('./parse-error');

var NATIVE_HTTP_OPTIONS = require ('./consts').NATIVE_HTTP_OPTIONS
var LIBRARY_SPECIFIC_OPTIONS = require ('./consts').LIBRARY_SPECIFIC_OPTIONS;

function httpResponseHandler (stream, reqParams, reqData, cb, response) {
var str;
Expand Down Expand Up @@ -219,10 +219,12 @@ ClickHouse.prototype.getReqParams = function () {
var urlObject = {};

// avoid to set defaults - node http module is not happy
NATIVE_HTTP_OPTIONS.forEach (function (k) {
if (this.options.hasOwnProperty(k))
urlObject[k] = this.options[k];
}, this);
for (var name of Object.keys(this.options)) {
if (!LIBRARY_SPECIFIC_OPTIONS.has(name)) {
urlObject[name] = this.options[name];
}
}

if (this.options.hasOwnProperty('user') || this.options.hasOwnProperty('password')) {
urlObject.auth = encodeURIComponent(this.options.user || 'default')
+ ':'
Expand Down
29 changes: 16 additions & 13 deletions src/consts.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
exports.NATIVE_HTTP_OPTIONS = [
'protocol',
'auth',
'host',
'hostname',
'port',
'path',
'localAddress',
'headers',
'agent',
'createConnection',
'timeout',
]
exports.LIBRARY_SPECIFIC_OPTIONS = new Set([
// "Auth" shorthand
'user',
'password',

// Database settings go to query string
'queryOptions',

// Driver options
'dataObjects',
'format',
'syncParser',
'omitFormat',
'readonly',
'useQueryString'
]);