Skip to content

Fix response header methods do not enforce the documented ASCII requirement - #2771

Closed
DBVamsi wants to merge 1 commit into
falconry:masterfrom
DBVamsi:fix/issue-2767
Closed

DBVamsi wants to merge 1 commit into
falconry:masterfrom
DBVamsi:fix/issue-2767

Conversation

@DBVamsi

@DBVamsi DBVamsi commented Oct 15, 2026

Copy link
Copy Markdown

Fixes #2767.

What changed

The fix is complete. Here's what was done:

Changes Summary

falcon/response.py

  • Added _prepare_header(name, value) helper function that validates ASCII names and Latin-1 encodable values
  • Updated set_header, append_header, and set_headers to use the new helper

tests/test_headers.py

  • Added TestHeaderASCIIValidation class with 17 new tests
  • Updated test_unicode_headers_contain_non_ascii to reflect new behavior

tests/test_error_reporter.py

  • Updated test_report_fatal_error_rendering_asgi_headers to expect 500 response instead of raised ValueError

Test Results

  • 171 tests in test_headers.py pass
  • 353 tests with "header" keyword pass
  • 3502 tests in main test suite pass
  • 548 tests in ASGI test suite pass

How it was verified

  • test(s) added/changed: tests/test_error_reporter.py, tests/test_headers.py
  • on the original code the new test fails (exit 1)
  • with the fix it passes (exit 0)
  • full test suite with the fix: green (20.1s)

This was worked on in conjunction with AI tools.

@vytas7

vytas7 commented Oct 15, 2026

Copy link
Copy Markdown
Member

Thanks for this PR!

I'm closing it for now, but feel free to reopen in accordance with our Contributing Guide (you need to open the PR and fill in the template yourself).

@vytas7 vytas7 closed this Oct 15, 2026
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.

Response header methods do not enforce the documented ASCII requirement

2 participants