New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

light-my-request

Package Overview
Dependencies
Maintainers
9
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

light-my-request - npm Package Compare versions

Comparing version 5.4.0 to 5.5.0

21

lib/request.js

@@ -107,8 +107,20 @@ 'use strict'

for (const field in headers) {
const fieldLowerCase = field.toLowerCase()
if (
(
fieldLowerCase === 'user-agent' ||
fieldLowerCase === 'content-type'
) && headers[field] === undefined
) {
this.headers[fieldLowerCase] = undefined
continue
}
const value = headers[field]
assert(value !== undefined, 'invalid value "undefined" for header ' + field)
this.headers[field.toLowerCase()] = '' + value
this.headers[fieldLowerCase] = '' + value
}
this.headers['user-agent'] = this.headers['user-agent'] || 'lightMyRequest'
if (('user-agent' in this.headers) === false) {
this.headers['user-agent'] = 'lightMyRequest'
}
this.headers.host = this.headers.host || options.authority || hostHeaderFromURL(parsedURL)

@@ -147,3 +159,6 @@

payload = JSON.stringify(payload)
this.headers['content-type'] = this.headers['content-type'] || 'application/json'
if (('content-type' in this.headers) === false) {
this.headers['content-type'] = 'application/json'
}
}

@@ -150,0 +165,0 @@

2

package.json
{
"name": "light-my-request",
"version": "5.4.0",
"version": "5.5.0",
"description": "Fake HTTP injection library",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -1927,1 +1927,26 @@ 'use strict'

})
test('should leave the headers user-agent and content-type undefined when the headers are explicitly set to undefined in the inject', (t) => {
t.plan(5)
const dispatch = function (req, res) {
t.ok(Array.isArray(req.rawHeaders))
t.equal(req.headers['user-agent'], undefined)
t.equal(req.headers['content-type'], undefined)
t.equal(req.headers['x-foo'], 'bar')
res.writeHead(200, { 'Content-Type': 'text/plain' })
res.end('Ok')
}
inject(dispatch, {
url: 'http://example.com:8080/hello',
method: 'POST',
headers: {
'x-foo': 'bar',
'user-agent': undefined,
'content-type': undefined
},
body: {}
}, (err, res) => {
t.error(err)
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc