Skip to content

Commit

Permalink
test: client, set body to null if bigger than CHUNK_LIMIT (#3064)
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak committed Apr 7, 2024
1 parent bc4b206 commit d399b3d
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/client-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,41 @@ test('stream throwOnError', async (t) => {
await t.completed
})

test('stream throwOnError, body is bigger than CHUNK_LIMIT', async (t) => {
t = tspl(t, { plan: 3 })

const errStatusCode = 500

const server = createServer((req, res) => {
res.writeHead(errStatusCode, { 'Content-Type': 'text/plain' })
res.end(Buffer.alloc(128 * 1024 + 1))
})
after(() => server.close())

server.listen(0, async () => {
const client = new Client(`http://localhost:${server.address().port}`)
after(() => client.close())

client.stream({
path: '/',
method: 'GET',
throwOnError: true,
opaque: new PassThrough()
}, ({ opaque: pt }) => {
pt.on('data', () => {
t.fail()
})
return pt
}, (e) => {
t.strictEqual(e.status, errStatusCode)
t.strictEqual(e.body, undefined)
t.ok(true, 'end')
})
})

await t.completed
})

test('steam throwOnError=true, error on stream', async (t) => {
t = tspl(t, { plan: 1 })

Expand Down

0 comments on commit d399b3d

Please sign in to comment.