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.34k stars 255 forks source link

Add server ip address to response object #328

Closed embeddinglayer closed 4 months ago

embeddinglayer commented 4 months ago

Ideally the response object should include the established server ip. Curl already offers that which is a better alternative to opening an entirely new socket connection to resolve that data.

import curl_cffi.requests as requests

resp = requests.get("https://example.com")
print(resp.ip)
embeddinglayer commented 4 months ago

Ideally the response object contains more data for the underlying connection such as CURLINFO_CERTINFO and CURLINFO_TLS_SESSION

perklet commented 4 months ago

Interesting idea! However, it seems that there is no such const as CURLINFO_NUM_CERTS.

embeddinglayer commented 4 months ago

Interesting idea! However, it seems that there is no such const as CURLINFO_NUM_CERTS.

Yeah, that code was unintentional looks like vs-code hadn't persisted to disk when I committed. Just removed it, I'll push the full code for certs in a later commit.

perklet commented 4 months ago

We need one or two unittests to make sure that this patch works as expected. Feel free to add them now or leave it there and I will add them later.