lexiforest / curl_cffi

Python binding for curl-impersonate fork via cffi. A http client that can impersonate browser tls/ja3/http2 fingerprints.
https://curl-cffi.readthedocs.io/
MIT License
2.52k stars 266 forks source link

headers problem #376

Closed l7123222l7 closed 2 months ago

l7123222l7 commented 3 months ago

When I use version 0.6.4, I can leave the request header empty. For example, changing upgrade-insecure-requests: 1 to upgrade-insecure-requests: This allows me to remove that header Because XHR interfaces don't have this kind of header However, in version 0.7.1, when I leave it empty It displays as follows instead of removing it:


GET / HTTP/1.1 Host: test.requestcatcher.com upgrade-insecure-requests:


But I also realized that some websites have empty headers For example, Authorization: It must be included to access, even if it's an empty value Is there a better way to handle this?

lexiforest commented 2 months ago

Yes, we changed that behavior to explicitly include empty-valued headers in 0.7.x. See: 041ff0c

To exclude empty headers, simply filter them out beforehead.

headers = {k: v for k, v in headers.items() if v}