fix: don't create `Headers` object if headers are already of that type
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.
That's indeed a bug, but what about fixing it in the __init__ method of Headers?
https://github.com/lexiforest/curl_cffi/blob/5074660e0f32b7531eca384cf5e2d8d0b1c94103/curl_cffi/requests/headers.py#L114-L115
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.
@lexiforest alrighty, will do it inside the Headers' __init__ it also makes more sense for me, and will add the unit test.
@lexiforest sorry for abandoning this, just got back here as we faced the issue again.
I have transferred the preservation of the encoding into the Headers __init__ and added two unit tests. Hope for a quick merge here!
p.s. didn't want to spend much time resolving conflicts, so just discarded the older commit, merged my branch with the main, and added the new commit on top.