Skip to content

feat(easy): expose native pre-request callbacks - #1

Closed
ldm0 wants to merge 2 commits into
moli-apple-sectrustfrom
feat/prerequest-callback
Closed

ldm0 wants to merge 2 commits into
moli-apple-sectrustfrom
feat/prerequest-callback

Conversation

@ldm0

@ldm0 ldm0 commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Applications currently need verbose/debug events or their own FFI to observe the point after connection/TLS setup and before sending a request. Add the native pre-request callback through Handler::prereq, Easy::prereq_function and Transfer::prereq_function.

Easy2::prereq(true) explicitly enables the handler callback. It is disabled by default and by reset, uses the existing boxed Inner for userdata, and allocates no callback storage in the Handler form. IP arguments borrow libcurl data; returning false aborts before sending the request. Easy and Transfer follow the existing owned/scoped callback model.

Two commits separate the related panic fix from the API:

  1. Propagate captured callback panics after Multi::perform, action and timeout return from C. An existing header-callback reproduction showed that the old Multi path left the deferred panic stored, suppressing later callbacks on that thread. The regression catches the original panic and successfully performs another transfer.
  2. Add curl-sys constants/callback ABI, the safe interfaces, version-aware ABI checks, and seven lifecycle regressions. Enable the existing three-platform HTTP/WebSocket workflow for the active integration branch.

GitHub HTTP/WebSocket/ABI CI passed on Linux, macOS and Windows.

Local validation on Linux:

  • cargo +1.96.1 fmt --all -- --check
  • Unit/integration suites with static-curl,http2,brotli,websocket,ws_start_frame_8_16_0: 78 passed, 1 ignored.
  • New prereq suite with both bundled and system libcurl: 7/7 passed in each configuration; 20/20 stress iterations passed with bundled libcurl.
  • Native ABI suite: 3,151 passed.
  • Documentation tests: 15 passed; network-dependent atexit executable passed.

Loopback suites ran with proxy environment variables cleared; the external-network atexit and documentation tests used the environment proxy. Coverage includes opt-in/disable/reset, moved handles and reused sockets, redirects, abort-before-headers, panic propagation/recovery, and owned/scoped callback restoration.

Based on moli-apple-sectrust (a0ea59f) to preserve the exact TLS integration currently pinned by Moli. Consumed by lexmount/moli#1702 to remove its handwritten prereq FFI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant