Skip to content

Curl backend: cancel the request when the sending thread is interrupted - #3049

Merged
adamw merged 7 commits into
masterfrom
curl-interruptible
Nov 2, 2026
Merged

adamw merged 7 commits into
masterfrom
curl-interruptible

Conversation

@adamw

@adamw adamw commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Part of #3043 (point 3).

Interrupting the thread that sends a request had no effect: the request ran until it completed.

Now the transfer is driven with curl's multi interface, waiting for at most 100ms at a time. Between the waits, the thread's interrupted flag is checked; if set, the transfer is stopped and an InterruptedException is thrown. The same check is done in the streaming response path, both while waiting for the headers and while reading the body.

As an interrupted (or otherwise failed) request now ends early, the curl handle, response buffers and output file are released on every exit, not only on success. Downloading to a file that can't be opened now fails, instead of writing the body to stdout.

Added native tests, named as HttpTest's cancel tests, which interrupt a thread waiting for a response, and one receiving a slow response body (default and streaming path).

@adamw
adamw merged commit 6852be9 into master Nov 2, 2026
27 checks passed
@adamw
adamw deleted the curl-interruptible branch November 2, 2026 17:29
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