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

[Feature] Respect headers order with the built-in requests #335

Open
Tagge opened this issue Jul 1, 2024 · 4 comments
Open

[Feature] Respect headers order with the built-in requests #335

Tagge opened this issue Jul 1, 2024 · 4 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@Tagge
Copy link

Tagge commented Jul 1, 2024

Is your feature request related to a problem? Please describe.
In some special instances, I have to be able to specify the order of my HTTP headers. Usually, with the original requests library, I would be able to do that by passing it an instance of Collections.OrderedDict containing my headers in the order desired. I have tried this approach with curl_cffi, and it doesn't seem to conserve the order of the headers no matter what I do. This is a useful feature as an order can sometimes be imposed by the webserver.

Describe the solution you'd like
Like for the requests library, it would be ideal to be able to pass an OrderedDict object that would automatically trigger the ordering of the headers.

Describe alternatives you've considered
Sadly, in those instances, I am forced to use something else.

@Tagge Tagge added the enhancement New feature or request label Jul 1, 2024
@perklet
Copy link
Collaborator

perklet commented Jul 2, 2024

Did you use the default_headers=False option to disable built-in headers? They may interfere with your custom headers.

@Tagge
Copy link
Author

Tagge commented Jul 2, 2024

Sadly it doesn't change it. Host is still being moved to the very top, and Accept is added automatically.

@perklet
Copy link
Collaborator

perklet commented Jul 2, 2024

I see. Host being reordered is a known issue. Are there any other headers that jump around unexpectedly? except for Host and Accept.

I will update the progress in this issue.

@Tagge
Copy link
Author

Tagge commented Jul 2, 2024

In my case, Accept-Encoding also has been swapped with Connection. I think it's mostly those ones.

@perklet perklet added this to the v0.8 milestone Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants