You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2fecd02
Browse filesBrowse the repository at this point in the historyBrowse files
fix: reject multiple values for singleton response headers (#2012)
## Summary
- reject empty or multiple-value arrays; normalize one-item arrays.
[edited by @yowainwright]
- apply the validation consistently to both `ctx.set(name, value)` and
`ctx.set(headers)`
- add regression coverage for both call forms
## Test plan
- `npm test`
- `npm run lint`
- `git diff --check`
Related to #1973
## Summary by Sourcery
Enforce single-value response headers consistently while retaining valid
multi-valued header support.
Bug Fixes:
- Reject multiple or empty values for singleton response headers while
preserving support for multi-valued headers such as Set-Cookie.
- Apply singleton-header validation consistently when setting individual
headers and header maps, including error responses.
Enhancements:
- Normalize single-element Content-Type and Content-Length arrays to
scalar header values and validate header maps before making assignments.
Tests:
- Add regression coverage for singleton-header validation,
normalization, atomic header assignment, single-read field access, and
error-response headers.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Bug Fixes**
* Setting multiple values for `Content-Type` or `Content-Length` now
throws an error, whether headers are set individually or together. Error
messages preserve the supplied header-name casing.
* When setting headers together, an invalid value prevents earlier
headers in the same assignment from being set.
* Single-value arrays are accepted for these headers, and each
object-form header value is read once.
* Error responses continue to apply other supplied headers, including
cookies, while ignoring supplied `Content-Type` and `Content-Length`
values.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Co-authored-by: shuaiyafei <16618929+shuaiyafei@users.noreply.github.com>
Co-authored-by: Jeff Wainwright <1074042+yowainwright@users.noreply.github.com>
0 commit comments