Skip to content

Commit 9ad456e

Browse files
committed
Allow elastic _bulk API to accept any Content-Type, and split request body on newlines
1 parent d7145ef commit 9ad456e

File tree

2 files changed

+1
-13
lines changed

2 files changed

+1
-13
lines changed

lib/handlers/elastic_bulk.js

+1-11
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,7 @@ async function handler (req, res) {
2626

2727
const docTarget = req.params.target || false
2828

29-
let streams
30-
if (
31-
req.headers['content-type'] &&
32-
req.headers['content-type'].indexOf('application/x-ndjson') > -1
33-
) {
34-
// ndjson body
35-
streams = req.body.split(/\n/)
36-
} else {
37-
// assume ndjson raw body
38-
streams = req.body.split(/\n/)
39-
}
29+
const streams = req.body.split(/\n/)
4030
let lastTags = false
4131
const promises = []
4232
if (streams) {

qryn_node.js

-2
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,9 @@ let fastify = require('fastify')({
243243
})
244244
const handlerElasticBulk = require('./lib/handlers/elastic_bulk.js').bind(this)
245245
writerMode && fastify.post('/_bulk', handlerElasticBulk, {
246-
'application/json': jsonParser,
247246
'*': rawStringParser
248247
})
249248
writerMode && fastify.post('/:target/_bulk', handlerElasticBulk, {
250-
'application/json': jsonParser,
251249
'*': rawStringParser
252250
})
253251

0 commit comments

Comments
 (0)