undici: Invalid body doesn't error

test('https://github.com/mcollina/undici/issues/807', (t) => {
  t.plan(2)

  const server = net.createServer(socket => {
    socket.write('HTTP/1.1 200 OK\r\n')
    socket.write('Content-Length: 1\r\n\r\n')
    socket.write('11111\r\n')
  })
  t.teardown(server.close.bind(server))

  server.listen(0, () => {
    const client = new Client(`http://localhost:${server.address().port}`)
    t.teardown(client.destroy.bind(client))

    client.request({
      path: '/',
      method: 'GET'
    }, (err, data) => {
      t.error(err)
      data.body.resume().on('end', () => {
        t.fail()
      })
    })
  })
})

I think the above request should fail. The body is longer than content-length.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 26 (26 by maintainers)

Commits related to this issue

Most upvoted comments

I haven’t forgotten and will get to this as soon as I can.

Yea. I think you might be right. I’ll open a Pr.

how are you doing?

I’ve been working non stop with deploying a new system into production. I think I can have a PR by end of week.

Yea. I think you might be right. I’ll open a Pr.

I don’t think we ever get an error from llhttp for that request so I’m not sure how it would help.

I have verified and we get an error as the response from execute.