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
I have encountered decoding errors with some requests that use ASCII encoding. Changing the default encoding to UTF-8 resolves these errors. I propose updating the normalize_header_key and normalize_header_value functions in _utils.py to use UTF-8 as the default encoding.
Steps to Reproduce
Call normalize_header_key or normalize_header_value with a non-ASCII string and no encoding specified.
Observe the decoding failure with ASCII encoding.
Change the encoding to UTF-8 and observe that the error is resolved.
Example Code
header_key_unicode="内容类型"normalized_key_unicode=normalize_header_key(header_key_unicode, lower=True)
# This raises a UnicodeEncodeError with ASCII encoding.normalized_key_unicode_utf8=normalize_header_key(header_key_unicode, lower=True, encoding="utf-8")
print(normalized_key_unicode_utf8) # Works correctly with UTF-8 encoding.
Proposed Solution
Modify the _utils.py file to use UTF-8 as the default encoding:
Using UTF-8 as the default encoding ensures that the functions can handle a wider range of input values without raising an error. UTF-8 encoding is capable of encoding a larger set of characters compared to ASCII.
The text was updated successfully, but these errors were encountered:
hey guys, can I work on this?
Thank you for your interest in this issue! I am currently working on a Pull Request to address this problem. If you have any suggestions or would like to review the changes, your input would be greatly appreciated.
Description
I have encountered decoding errors with some requests that use ASCII encoding. Changing the default encoding to UTF-8 resolves these errors. I propose updating the
normalize_header_key
andnormalize_header_value
functions in_utils.py
to use UTF-8 as the default encoding.Steps to Reproduce
normalize_header_key
ornormalize_header_value
with a non-ASCII string and no encoding specified.Example Code
Proposed Solution
Modify the _utils.py file to use UTF-8 as the default encoding:
Rationale
Using UTF-8 as the default encoding ensures that the functions can handle a wider range of input values without raising an error. UTF-8 encoding is capable of encoding a larger set of characters compared to ASCII.
The text was updated successfully, but these errors were encountered: