Comparing version 7.1.1 to 7.1.2
{ | ||
"name": "bent", | ||
"version": "7.1.1", | ||
"version": "7.1.2", | ||
"description": "Functional HTTP client for Node.js w/ async/await.", | ||
@@ -5,0 +5,0 @@ "main": "src/nodejs.js", |
@@ -136,3 +136,5 @@ 'use strict' | ||
} else if (typeof body === 'object') { | ||
req.setHeader('content-type', 'application/json') | ||
if (!c.has('content-type')) { | ||
req.setHeader('content-type', 'application/json') | ||
} | ||
body = Buffer.from(JSON.stringify(body)) | ||
@@ -139,0 +141,0 @@ } else { |
@@ -8,2 +8,4 @@ /* globals atob, it */ | ||
const http = require('http') | ||
const test = it | ||
@@ -162,2 +164,19 @@ | ||
}) | ||
test('manually-set content-type header when body is present', async () => { | ||
const server = http.createServer((request, response) => { | ||
response.statusCode = request.headers['content-type'] === 'application/jose+json' ? 200 : 400 | ||
response.end() | ||
}) | ||
await new Promise((resolve, reject) => { | ||
server.listen(9999, () => { | ||
resolve() | ||
}) | ||
}) | ||
const request = bent('POST') | ||
const response = request('http://localhost:9999', { ok: true }, { 'content-type': 'application/jose+json' }) | ||
const info = await response | ||
same(info.statusCode, 200) | ||
server.close() | ||
}) | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21306
519
4