in lib/post-es.js [81:115]
exports.send = function(service, target, records, callback) {
var req = new AWS.HttpRequest(service.endpoint);
req.method = 'POST';
req.path = service.path + '/_bulk';
if(req.path.charAt(0) != '/') {
req.path = '/' + req.path;
}
req.region = service.region;
req.headers['presigned-expires'] = false;
req.headers['Host'] = service.endpoint.host;
req.body = Buffer.concat(
records.map(function(record)
{ return Buffer.concat([new Buffer('{"index":{"_id":"' + record.key + '"}}' + "\n", 'utf-8'), record.data, new Buffer("\n", 'utf-8')]); }));
var signer = new AWS.Signers.V4(req , 'es');
signer.addAuthorization(service.credentials, new Date());
var send = new AWS.NodeHttpClient();
send.handleRequest(req, null, function(httpResp) {
var respBody = '';
httpResp.on('data', function (chunk) {
respBody += chunk;
});
httpResp.on('end', function (chunk) {
if(httpResp.statusCode == 200) {
callback(null);
} else {
callback(new Error("Error posting to Amazon ElasticSearch: HTTP Status Code: '" + httpResp.statusCode + "', body '" + respBody + "'"));
}
});
}, function(err) {
callback(new Error("Error posting to Amazon ElasticSearch: '" + err + "'"));
});
};