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

response content-length mismatch waits for timeout #429

Closed
ronag opened this issue Sep 23, 2020 · 3 comments
Closed

response content-length mismatch waits for timeout #429

ronag opened this issue Sep 23, 2020 · 3 comments
Labels
bug Something isn't working Status: in-progress This issue/pr is currently being worked on

Comments

@ronag
Copy link
Member

ronag commented Sep 23, 2020

I'm not sure but I think it should be possible to detect a response content-length mismatch without waiting for timeout. Unclear why the parser does not detect this.

test('response invalid content length', (t) => {
  t.plan(3)

  const server = createServer((req, res) => {
    res.writeHead(200, {
      'content-length': 10
    })
    res.end('123')
  })
  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.on('disconnect', (err) => {
      t.strictEqual(err.code, 'UND_ERR_SOCKET')
    })

    client.request({
      path: '/',
      method: 'GET'
    }, (err, data) => {
      t.error(err)
      data.body
        .on('end', () => {
          t.fail()
        })
        .on('error', (err) => {
          t.strictEqual(err.code, 'UND_ERR_SOCKET')
        })
        .resume()
    })
  })
})
@ronag ronag added bug Something isn't working Status: help-wanted This issue/pr is open for contributions labels Sep 23, 2020
@ronag
Copy link
Member Author

ronag commented Sep 23, 2020

Would be even better if we could throw a descriptive error, e.g. "response body content-length mismatch"

@simone-sanfratello
Copy link
Contributor

I'll work on that

@Ethan-Arrowood Ethan-Arrowood added Status: in-progress This issue/pr is currently being worked on and removed Status: help-wanted This issue/pr is open for contributions labels Apr 1, 2021
@ronag ronag closed this as completed Jun 30, 2021
@ronag
Copy link
Member Author

ronag commented Jun 30, 2021

nodejs/node#39133

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Status: in-progress This issue/pr is currently being worked on
Projects
None yet
Development

No branches or pull requests

3 participants