[Backport 7.x] Add ability to disable the http agent (#1258)

Co-authored-by: Tomas Della Vedova <delvedor@users.noreply.github.com>
This commit is contained in:
github-actions[bot]
2020-07-13 15:09:22 +02:00
committed by GitHub
parent 581b0f3a35
commit e864c1db99
8 changed files with 117 additions and 13 deletions

View File

@ -1093,6 +1093,32 @@ test('Random selector', t => {
})
})
test('Disable keep alive agent', t => {
t.plan(3)
function handler (req, res) {
t.strictEqual(req.headers.connection, 'close')
res.setHeader('Content-Type', 'application/json;utf=8')
res.end(JSON.stringify({ hello: 'world' }))
}
buildServer(handler, ({ port }, server) => {
const client = new Client({
node: `http://localhost:${port}`,
agent: false
})
client.search({
index: 'test',
q: 'foo:bar'
}, (err, { body }) => {
t.error(err)
t.deepEqual(body, { hello: 'world' })
server.stop()
})
})
})
test('name property as string', t => {
t.plan(1)