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

[BUG] Bytes data is sent as "application/x-www-form-urlencoded" #379

Open
vevv opened this issue Sep 7, 2024 · 0 comments
Open

[BUG] Bytes data is sent as "application/x-www-form-urlencoded" #379

vevv opened this issue Sep 7, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@vevv
Copy link

vevv commented Sep 7, 2024

Describe the bug
Raw byte data provided with data= to requests.post has header application/x-www-form-urlencoded. This is not desireable as some servers will refuse a request with that header

To Reproduce

from curl_cffi import requests
resp = requests.post('https://httpbin.org/anything', data=b'test')

print(resp.json()['headers']['Content-Type'])

Expected behavior
Should be application/octet-stream unless specified otherwise.

Requests only applies this header to types other than str and bytes (e.g. dict).
https://github.com/psf/requests/blob/f12ccbef6d6b95564da8d22e280d28c39d53f0e9/src/requests/models.py#L552-L562

Versions

  • OS: Windows 10
  • curl_cffi 0.7.1

Additional context

  • Sync session, but issue present on all.

https://github.com/lexiforest/curl_cffi/blob/8e69ad74f6fbff2a58148f0712c8f2247517e366/curl_cffi/requests/session.py#L450-L454C64

@vevv vevv added the bug Something isn't working label Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant