Skip to content

Conversation

cAtaman
Copy link
Contributor

@cAtaman cAtaman commented Aug 6, 2021

Fix the handling of defaults passed to the Headers constructor. It now has uniform behavior with headers added with Headers.add

This fix uses Headers.extend to add defaults as opposed to List.extend used previously. Using the Headers' extend method allows all internal checks and conversions to be done on the default values passed.

For an example, newlines are not allowed in headers.

    h1 = Headers([('X-Example', 'foo\r\n bar')])
    h2 = Headers()
    h2.add('X-Example', 'foo\r\n bar')

Before this fix h1 would get created while h2 would fail. Now they would both fail.

Checklist:

  • Add tests that demonstrate the correct behavior of the change. Tests should fail without the change.
  • Add or update relevant docs, in the docs folder and in code.
  • Add an entry in CHANGES.rst summarizing the change and linking to the issue.
  • Add .. versionchanged:: entries in any relevant code docs.
  • Run pre-commit hooks and fix any issues.
  • Run pytest and tox, no tests failed.

@davidism davidism added this to the 2.1.0 milestone Aug 6, 2021
@davidism davidism force-pushed the 1608-fix-header-newline-handling branch from 3cd2e2f to 86c3e96 Compare August 6, 2021 13:29
this would allow all internal checks and conversions to be done on default values
@davidism davidism force-pushed the 1608-fix-header-newline-handling branch from 86c3e96 to a2063c1 Compare August 6, 2021 13:34
@davidism davidism merged commit eba0ec0 into pallets:main Aug 6, 2021
@davidism davidism deleted the 1608-fix-header-newline-handling branch August 6, 2021 13:36
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent handling of newlines in Headers object
2 participants