Skip to content
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

fix: don't create Headers object if headers are already of that type #401

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

serozhenka
Copy link

@serozhenka serozhenka commented Oct 3, 2024

The Headers.encoding gets stripped off in the BaseSession._set_curl_options method if the headers are already of type Headers. This PR aims to fix this by checking whether the headers are of the expected type.

@lexiforest
Copy link
Owner

That's indeed a bug, but what about fixing it in the __init__ method of Headers?

elif isinstance(headers, Headers):
self._list = list(headers._list)

The _encoding attribute is not copied from the headers passed in.

Anyway, it would be better to add a simple unittest in the test_headers.py file.

@serozhenka
Copy link
Author

serozhenka commented Oct 3, 2024

@lexiforest alrighty, will do it inside the Headers' __init__ it also makes more sense for me, and will add the unit test.

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.

2 participants