bent
Advanced tools
Comparing version 7.3.8 to 7.3.9
{ | ||
"name": "bent", | ||
"version": "7.3.8", | ||
"version": "7.3.9", | ||
"description": "Functional HTTP client for Node.js w/ async/await.", | ||
@@ -5,0 +5,0 @@ "main": "src/nodejs.js", |
@@ -32,6 +32,10 @@ 'use strict' | ||
} else if (typeof arg === 'object') { | ||
if (headers) { | ||
throw new Error('Cannot set headers twice.') | ||
if (Array.isArray(arg) || arg instanceof Set) { | ||
arg.forEach(code => statusCodes.add(code)) | ||
} else { | ||
if (headers) { | ||
throw new Error('Cannot set headers twice.') | ||
} | ||
headers = arg | ||
} | ||
headers = arg | ||
} else { | ||
@@ -38,0 +42,0 @@ throw new Error(`Unknown type: ${typeof arg}`) |
@@ -123,2 +123,20 @@ /* globals atob, it */ | ||
test('multiple status', async () => { | ||
const request = bent('string', [200, 201]) | ||
const str200 = await request(u('/echo.js?body=ok')) | ||
same(str200, 'ok') | ||
const str201 = await request(u('/echo.js?statusCode=201&body=ok')) | ||
same(str201, 'ok') | ||
try { | ||
await request(u('/echo.js?statusCode=202&body=ok')) | ||
throw new Error('Call should have thrown.') | ||
} catch (e) { | ||
same(e.message, process.browser ? null : 'Accepted') | ||
// basic header test | ||
same(e.headers['content-length'], '2') | ||
} | ||
}) | ||
test('PUT stream', async () => { | ||
@@ -125,0 +143,0 @@ const body = Buffer.from(Math.random().toString()) |
26579
670