fix(cli): --write-out %{onerror} and %{urlnum} to stderr (test 1188)#119
Merged
jonwiggins merged 5 commits intomainfrom Mar 28, 2026
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--failHTTP errors in multi-URL mode by usingeasy.last_response()to get the actual response with headers, enabling proper--include,--output, and--write-outsupportperform_with_retryto not retry non-retriable--failHTTP errors (e.g., 404 with--retry)Test plan
--write-outwith%{onerror}and%{urlnum}to stderr)--retryand-fon an HTTP 404 response)--fail/--fail-with-bodytests)cargo clippy,cargo test,cargo fmtpass🤖 Generated with Claude Code