Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function setContentLength () {
if (isTypedArray(self.body)) {
self.body = new Buffer(self.body)
}
if (!self.hasHeader('content-length')) {
var length
if (typeof self.body === 'string') {
length = Buffer.byteLength(self.body)
}
else if (Array.isArray(self.body)) {
length = self.body.reduce(function (a, b) {return a + b.length}, 0)
}
else {
length = self.body.length
}
if (length) {
function setContentLength () {
if (isTypedArray(self.body)) {
self.body = new Buffer(self.body)
}
if (!self.hasHeader('content-length')) {
var length
if (typeof self.body === 'string') {
length = Buffer.byteLength(self.body)
}
else if (Array.isArray(self.body)) {
length = self.body.reduce(function (a, b) {return a + b.length}, 0)
}
else {
length = self.body.length
}
if (length) {
function setContentLength () {
if (isTypedArray(self.body)) {
self.body = new Buffer(self.body)
}
if (!self.hasHeader('content-length')) {
var length
if (typeof self.body === 'string') {
length = Buffer.byteLength(self.body)
}
else if (Array.isArray(self.body)) {
length = self.body.reduce(function (a, b) {return a + b.length}, 0)
}
else {
length = self.body.length
}
if (length) {
function setContentLength () {
if (isTypedArray(self.body)) {
self.body = new Buffer(self.body)
}
if (!self.hasHeader('content-length')) {
var length
if (typeof self.body === 'string') {
length = Buffer.byteLength(self.body)
}
else if (Array.isArray(self.body)) {
length = self.body.reduce(function (a, b) {return a + b.length}, 0)
}
else {
length = self.body.length
}
if (length) {
function setContentLength () {
if (isTypedArray(self.body)) {
self.body = Buffer.from(self.body)
}
if (!self.hasHeader('content-length')) {
var length
if (typeof self.body === 'string') {
length = Buffer.byteLength(self.body)
} else if (Array.isArray(self.body)) {
length = self.body.reduce(function (a, b) { return a + b.length }, 0)
} else {
length = self.body.length
}
if (length) {
self.setHeader('content-length', length)
} else {
function setContentLength () {
if (isTypedArray(self.body)) {
self.body = Buffer.from(self.body)
}
if (!self.hasHeader('content-length')) {
var length
if (typeof self.body === 'string') {
length = Buffer.byteLength(self.body)
} else if (Array.isArray(self.body)) {
length = self.body.reduce(function (a, b) { return a + b.length }, 0)
} else {
length = self.body.length
}
if (length) {
self.setHeader('content-length', length)
} else {
function setContentLength () {
if (isTypedArray(self.body)) {
self.body = new Buffer(self.body)
}
if (!self.hasHeader('content-length')) {
var length
if (typeof self.body === 'string') {
length = Buffer.byteLength(self.body)
}
else if (Array.isArray(self.body)) {
length = self.body.reduce(function (a, b) {return a + b.length}, 0)
}
else {
length = self.body.length
}
if (length) {
function setContentLength () {
if (isTypedArray(self.body)) {
self.body = Buffer.from(self.body)
}
if (!self.hasHeader('content-length')) {
var length
if (typeof self.body === 'string') {
length = Buffer.byteLength(self.body)
} else if (Array.isArray(self.body)) {
length = self.body.reduce(function (a, b) { return a + b.length }, 0)
} else {
length = self.body.length
}
if (length) {
self.setHeader('content-length', length)
} else {
function setContentLength () {
if (isTypedArray(self.body)) {
self.body = new Buffer(self.body)
}
if (!self.hasHeader('content-length')) {
var length
if (typeof self.body === 'string') {
length = Buffer.byteLength(self.body)
}
else if (Array.isArray(self.body)) {
length = self.body.reduce(function (a, b) {return a + b.length}, 0)
}
else {
length = self.body.length
}
if (length) {