Skip to content

fix(cli): --write-out %{onerror} and %{urlnum} to stderr (test 1188)#119

Merged
jonwiggins merged 5 commits intomainfrom
optio/task-1b1f9089-bcfc-4103-af01-96c1b1f7674f
Mar 28, 2026
Merged

fix(cli): --write-out %{onerror} and %{urlnum} to stderr (test 1188)#119
jonwiggins merged 5 commits intomainfrom
optio/task-1b1f9089-bcfc-4103-af01-96c1b1f7674f

Conversation

@jonwiggins
Copy link
Copy Markdown
Owner

@jonwiggins jonwiggins commented Mar 28, 2026

Summary

  • Handle --fail HTTP errors in multi-URL mode by using easy.last_response() to get the actual response with headers, enabling proper --include, --output, and --write-out support
  • Fix perform_with_retry to not retry non-retriable --fail HTTP errors (e.g., 404 with --retry)

Test plan

  • Test 1188 passes (--write-out with %{onerror} and %{urlnum} to stderr)
  • Test 752 passes (--retry and -f on an HTTP 404 response)
  • Tests 24, 349, 361 pass (related --fail / --fail-with-body tests)
  • Tests 1-100, 700-780, 1100-1400 show no regressions
  • cargo clippy, cargo test, cargo fmt pass

🤖 Generated with Claude Code

Optio Agent and others added 5 commits March 27, 2026 23:41
Change the fail_on_error error message from "HTTP error NNN (fail_on_error
enabled)" to "The requested URL returned error: NNN" to match curl's
%{errormsg} format. This fixes --write-out %{onerror} and %{urlnum} output
to stderr (curl test 1188).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ded 0.1.0 (#115)

The default User-Agent was hardcoded as "curl/0.1.0" in h1, h2, h3, and
easy.rs (CONNECT proxy). After --next resets headers, subsequent request
groups fell back to this stale default instead of the actual version,
causing curl tests 386, 430, 431, 432 to fail.

Replace all instances with concat!("curl/", env!("CARGO_PKG_VERSION"))
so the default User-Agent always matches the crate version.

Co-authored-by: Optio Agent <optio-agent@noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…nd output

When multiple URLs are used with --fail, the Easy handle's fail_on_error
flag causes perform_async() to return an Err instead of Ok(response).
The error branch was using a dummy response for write-out and not writing
headers to the output file, which broke --write-out variables like
%{onerror}, %{urlnum}, %{exitcode}, and %{errormsg} when combined with
%{stderr}, and also broke --include output to files.

Fix by detecting --fail HTTP errors (curl code 22) in the Err branch and
using easy.last_response() to retrieve the actual response stored before
the error was returned. This provides correct headers for --include
output and proper response data for write-out variable expansion.

Passes curl test 1188.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When --fail causes perform() to return Err(Error::Http) for non-retriable
HTTP status codes (like 404), the retry loop should not retry. Previously,
the Err branch retried unconditionally, causing an extra request when
--retry was used with --fail on non-retriable responses.

(curl compat: test 752)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jonwiggins jonwiggins changed the title fix(cli): handle --fail HTTP errors in multi-URL mode for write-out and output fix(cli): --write-out %{onerror} and %{urlnum} to stderr (test 1188) Mar 28, 2026
@jonwiggins jonwiggins merged commit 233f3c0 into main Mar 28, 2026
7 checks passed
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