Skip to content

gh-105530: Support sending HTTP header values with RFC 2047 #105621

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 1 commit into
base: main
Choose a base branch
from

Conversation

michaelfm1211
Copy link

@michaelfm1211 michaelfm1211 commented Jun 10, 2023

Currently, sending an HTTP header with non-ISO-8859-1 (latin-1) characters will result in a UnicodeEncodeError being thrown. This change adds support for such characters in the header values using RFC 2047 encoded-word format.

This change was originally part of #105531, which originally handled RFC 2047 for both receiving and sending. The receiving part could be a breaking change and might be better suited as part of a bigger change. However, this change for the sending part should not make any breaking changes. If an application already supports RFC 2047 encoded-word format, then it will still work.


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

Currently, sending an HTTP header with non-ISO-8859-1 (latin-1)
characters will result in a UnicodeEncodeError being thrown. This change
adds support for such characters in the header values using RFC 2047
encoded-word format.
@michaelfm1211 michaelfm1211 changed the title gh-105530: Support sending HTTP header values with RFC 2047 gh-105530: Support sending Unicdoe HTTP header values with RFC 2047 Jun 10, 2023
@michaelfm1211 michaelfm1211 changed the title gh-105530: Support sending Unicdoe HTTP header values with RFC 2047 gh-105530: Support sending Unicode HTTP header values with RFC 2047 Jun 10, 2023
@michaelfm1211 michaelfm1211 changed the title gh-105530: Support sending Unicode HTTP header values with RFC 2047 gh-105530: Support sending HTTP header values with RFC 2047 Jun 10, 2023
@arhadthedev
Copy link
Member

cc @python/email-team

@arhadthedev arhadthedev added the stdlib Python modules in the Lib dir label Jun 10, 2023
@davidism
Copy link

davidism commented Jun 27, 2023

This does not seem correct. HTTP is not email, and HTTP/1.1 headers don't follow a consistent encoding standard, beyond "somehow encode to only use ASCII or Latin-1 bytes". Using an encoding scheme from email/mime would be unexpected for an HTTP client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review stdlib Python modules in the Lib dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants