Skip to content

fix(http): use crate version for default User-Agent (tests 386, 430-432)#115

Merged
jonwiggins merged 1 commit intomainfrom
optio/task-24e230e8-9b36-4964-ace6-9d5102f236b0
Mar 27, 2026
Merged

fix(http): use crate version for default User-Agent (tests 386, 430-432)#115
jonwiggins merged 1 commit intomainfrom
optio/task-24e230e8-9b36-4964-ace6-9d5102f236b0

Conversation

@jonwiggins
Copy link
Copy Markdown
Owner

Summary

  • Fixed default User-Agent string in HTTP/1.1, HTTP/2, HTTP/3, and CONNECT proxy code from hardcoded curl/0.1.0 to concat!("curl/", env!("CARGO_PKG_VERSION")) so it always matches the actual crate version
  • This fixes --next + --config chaining where subsequent request groups (after --next resets headers) fell back to the stale 0.1.0 default instead of 0.2.2

Test plan

  • curl tests 386, 430, 431, 432 now pass (were all failing due to User-Agent mismatch after --next)
  • cargo fmt and cargo clippy clean
  • All 925 liburlx lib tests pass
  • All 336 urlx-cli tests pass
  • No regressions in curl test suite (tests 1-50 and 380-440 verified)

🤖 Generated with Claude Code

…ded 0.1.0

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: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jonwiggins jonwiggins merged commit 6ed6ae4 into main Mar 27, 2026
7 checks passed
jonwiggins added a commit that referenced this pull request Mar 28, 2026
…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>
jonwiggins added a commit that referenced this pull request Mar 28, 2026
…119)

* fix(cli): use curl-compatible error message for --fail HTTP errors

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>

* fix(http): use crate version for default User-Agent instead of hardcoded 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>

* fix(cli): handle --fail HTTP errors in multi-URL mode for write-out and 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>

* fix(cli): don't retry --fail HTTP errors in perform_with_retry

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>

---------

Co-authored-by: Optio Agent <optio-agent@noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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