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

Add FFI bindings for blocking network transfers via libcurl's easy interface #665

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

rdw-software
Copy link
Member

@rdw-software rdw-software commented Feb 17, 2025

First part of binding the blocking client APIs from libcurl. There's a few ugly parts that won't map cleanly:

curl_easy_setopt_by_name replacing curl_easy_setopt

The plan is to export a custom wrapper API instead of the one that curl offers to set transfer options:

  • libcurl uses numeric IDs for the options, but generates them with macro expansions and offsets
  • I really don't want to sync even more types (ideally none, but that's not happening anytime soon)
  • Ergo I'm not going to duplicate the preprocessed header types, or generate them on-the fly
  • Instead, the API should take the name and/or curl_easyoption pointer and handle the rest
  • There's probably no one who wants do pass random numbers from Lua anyway... so yeah, let's not

If curl_easy_setopt isn't going to be exposed, the name can be reused. Otherwise, it could get an alias.

curl_easy_getinfo_by_name potentially replacing curl_easy_getinfo (?)

I'd rather not duplicate CURLINFO even though it's not as problematic. Maybe another name-based lookup function will do? In that case, there's probably no need to deal with numeric IDs. I'll need to do some more testing first.

curl_easy_ssls_export and other callback-based APIs

Callbacks really aren't something I like to see, but they just won't die. Unlike the VM, when JIT optimizations aren't disabled. It won't be an issue for curl's easy interface because it's blocking. But for parallel transfers (multi interface) and the libuv integration, there might not be any way around implementing another event/polling wrapper API. Not great?

NYI: Async DNS resolution

The blocking transfer APIs aren't going to break any speed records. So it shouldn't be a problem if DNS resolution uses the default mechanism. On Windows, it seems like AsynchResolver is actually enabled by default... lucky accident.


Resolves #655 (once done). Still needs testing for at least the most basic use cases, and name-based lookups.

@rdw-software rdw-software force-pushed the 655-libcurl-easy-bindings branch from 0ce6ce4 to 1dfcfbe Compare February 22, 2025 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add FFI bindings for libcurl's "easy" interface
1 participant