Skip to content

Conversation

@mcollina
Copy link
Member

Summary

  • Allows Connection header to contain comma-separated list of connection option tokens (header names) per RFC 7230 Section 6.1
  • Previously only close or keep-alive were accepted, now any valid HTTP token is allowed
  • Sets request.reset = true if close is present in the token list

Test plan

  • Added tests for close and keep-alive values
  • Added test for custom header name as connection option
  • Added test for comma-separated list of connection options
  • Added test for rejecting invalid tokens
  • All existing tests pass

Fixes #4774

…per RFC 7230

Per RFC 7230 Section 6.1, the Connection header can contain a
comma-separated list of connection option tokens (header names)
that should be removed by proxies before forwarding the message.

Previously, undici only allowed 'close' or 'keep-alive' as Connection
header values. This change allows any valid HTTP token as a connection
option, enabling RFC-compliant requests like:

  Connection: X-Custom-Header
  Connection: close, X-Custom-Header

Fixes: #4774
Signed-off-by: Matteo Collina <hello@matteocollina.com>
}

if (value === 'close') {
const tokens = value.split(',').map(t => t.trim().toLowerCase())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are iterating over them twice, can we do it at one pass?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could actually lowercase before split.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support sending Connection header with connection-specific header names per RFC 7230

3 participants