Added protocol validation
This commit is contained in:
@ -6,7 +6,7 @@ const https = require('https')
|
||||
const debug = require('debug')('elasticsearch')
|
||||
const decompressResponse = require('decompress-response')
|
||||
const pump = require('pump')
|
||||
const { TimeoutError } = require('./errors')
|
||||
const { TimeoutError, ConfigurationError } = require('./errors')
|
||||
|
||||
class Connection {
|
||||
constructor (opts = {}) {
|
||||
@ -21,6 +21,10 @@ class Connection {
|
||||
this._status = opts.status || Connection.statuses.ALIVE
|
||||
this.roles = opts.roles || defaultRoles
|
||||
|
||||
if (!['http:', 'https:'].includes(this.url.protocol)) {
|
||||
throw new ConfigurationError(`Invalid protocol: '${this.url.protocol}'`)
|
||||
}
|
||||
|
||||
const agentOptions = Object.assign({}, {
|
||||
keepAlive: true,
|
||||
keepAliveMsecs: 1000,
|
||||
|
||||
Reference in New Issue
Block a user