Skip to content

Commit

Permalink
update use of Buffer to Buffer.from. Add "Host" header to requests ag…
Browse files Browse the repository at this point in the history
…ainst elasticsearch.
  • Loading branch information
Bob Potterveld committed Apr 30, 2021
1 parent d326669 commit 7a40088
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lambda/proxy-es/lib/logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ module.exports=function(event, context, callback){
var params = {
DeliveryStreamName: process.env.FIREHOSE_NAME, /* required */
Record: { /* required */
Data: new Buffer(objJsonStr) /* Strings will be Base-64 encoded on your behalf */ /* required */
Data: Buffer.from(objJsonStr) /* Strings will be Base-64 encoded on your behalf */ /* required */
}
}

Expand All @@ -101,4 +101,4 @@ module.exports=function(event, context, callback){
else console.log(data) // successful response
})

}
}
6 changes: 3 additions & 3 deletions lambda/proxy-es/lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ var Url=require('url')

module.exports=function(opts){

var url=Url.parse(opts.url)
var request={
const url=Url.parse(opts.url)
const request={
host:url.hostname,
method:opts.method.toUpperCase(),
url:url.href,
path:url.path,
headers:opts.headers || {}
}

request.headers['Host']=request.host;
if(opts.body){
if(Array.isArray(opts.body)){
opts.body=opts.body.map(JSON.stringify).join('\n')+'\n'
Expand Down
23 changes: 17 additions & 6 deletions lambda/proxy-es/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7a40088

Please sign in to comment.