curl_cffi
curl_cffi copied to clipboard
[BUG] Explicit Content-Type is being overwritten
Describe the bug curl_cffi still messes with Content-Type headers. Even If I set Content-Type to "text/plain" manually, and send a POST request with string data, it will be encoded with "application/octet-stream".
To Reproduce
from curl_cffi import requests
resp = requests.post(url="https://httpbin.dev/headers", data="test", headers={"Content-Type": "text/plain"})
print(resp.json()["headers"]["Content-Type"])
Expected behavior User-provided Content-Type headers are expected.
Versions
- OS: Windows 10
- curl_cffi version: 0.7.2
Additional Context Unrelated, but this part is incorrect:
if isinstance(data, dict) and method != "POST":
_update_header_line(header_lines, "Content-Type", "application/x-www-form-urlencoded")
This should run on POST as well, it's usually used with POST or PUT.
Also, "text/plain" is probably more appropriate for strings.