Skip to content

[BUG] Unsupported ctypes for getinfo to work #407

@ringus1

Description

@ringus1

Describe the bug
Some CurlInfo constants can't be retrieved seemingly because types are not supported, such as curl_off_t.

Raw CURL command

> curl --compressed -so /dev/null http://www.whatsmyip.org/http-compression-test/ -w '%{size_download}'
256

Python attempt

> import curl_cffi

> curl = curl_cffi.Curl()
> curl.setopt(curl_cffi.CurlOpt.URL, "http://www.whatsmyip.org/http-compression-test/")
> curl.setopt(curl_cffi.CurlOpt.ACCEPT_ENCODING, 'gzip')
> curl.perform()

> curl.getinfo(curl_cffi.CurlInfo.SIZE_DOWNLOAD_T)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.12/site-packages/curl_cffi/curl.py", line 243, in getinfo
    c_value = ffi.new(ret_option[option & 0xF00000])
                      ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
KeyError: 6291456

Some more insight

> from curl_cffi._wrapper import ffi, lib
> ffi.getctype("long")
'long'
> ffi.getctype("char")
'char'
> ffi.getctype("curl_off_t")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ffi.error: undefined type name
curl_off_t

Expected behavior
CurlInfo options can be retrieved via Curl.getinfo

Versions

  • OS: linux x64
  • certifi==2024.8.30
  • cffi==1.17.1
  • curl_cffi==0.7.2
  • pycparser==2.22
  • typing_extensions==4.12.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions