Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: client, set body to null if bigger than CHUNK_LIMIT #3064

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading