Skip to content

gh-105622: Parse HTTP headers with default email policy #105918

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

michaelfm1211
Copy link

@michaelfm1211 michaelfm1211 commented Jun 19, 2023

Updates http.client._parse_header_lines to use email.policy.default when parsing HTTP headers. An email policy should always be specified and allows the http module to use email's header registry.


📚 Documentation preview 📚: https://cpython-previews--105918.org.readthedocs.build/

Updates http.client._parse_header_lines to use email.policy.default when
parsing HTTP headers. An email policy should always be specified and
allows the http module to use email's header registry.
@arhadthedev
Copy link
Member

@vstinner, probably?

@python-cla-bot
Copy link

The following commit authors need to sign the Contributor License Agreement:

CLA signed

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

Can you add some examples of headers previously accepted and no longer accepted by the new policy? Add them to tests.

self.fail('Date value not in %r format' % dateformat)
date = fileheaders.get('Date')
self.assertIsInstance(date, email.headerregistry.DateHeader,
"Date is not an instance of email.headerregistery.DateHeader")
Copy link
Member

Choose a reason for hiding this comment

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

I don't think that the 3rd argument is needed.

@vstinner
Copy link
Member

Is this change backward incompatible?

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

Successfully merging this pull request may close these issues.

4 participants