Skip to content

tool_cb_hdr: with -J, use the redirect name as a backup - #20430

Closed
bagder wants to merge 1 commit into
masterfrom
bagder/redirect-cd
Closed

tool_cb_hdr: with -J, use the redirect name as a backup#20430
bagder wants to merge 1 commit into
masterfrom
bagder/redirect-cd

Conversation

@bagder

@bagder bagder commented Jan 25, 2026

Copy link
Copy Markdown
Member

The -J / --remote-header-name logic now records the file name part used in the redirects so that it can use the last one as a name if no Content-Disposition header arrives.

Add three tests to verify.

@github-actions github-actions Bot added the tests label Jan 25, 2026
@bagder
bagder marked this pull request as ready for review January 25, 2026 16:07
@bagder
bagder requested a review from Copilot January 25, 2026 16:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request enhances the -J/--remote-header-name option to use the filename from redirect Location headers as a fallback when no Content-Disposition header is provided. This improves user experience by providing a more meaningful output filename based on the redirect path when the server doesn't explicitly set a filename via Content-Disposition.

Changes:

  • Modified content_disposition() function to parse and store filenames from Location headers as a temporary measure
  • Added test1641 to verify Content-Disposition takes precedence over Location header filename
  • Added test1642 to verify Location header filename is used when Content-Disposition is absent
  • Updated documentation to describe the new fallback behavior starting in version 8.19.0

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/tool_cb_hdr.c Added Location header parsing logic to extract and store filename as fallback before Content-Disposition processing
tests/data/test1641 Test case verifying Content-Disposition filename is used when present after redirect
tests/data/test1642 Test case verifying Location header filename is used when Content-Disposition is absent
tests/data/Makefile.am Added test1641 to the test file list
docs/cmdline-opts/remote-header-name.md Documented the new fallback behavior for version 8.19.0

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/tool_cb_hdr.c Outdated
Comment thread tests/data/Makefile.am Outdated
@bagder

bagder commented Jan 25, 2026

Copy link
Copy Markdown
Member Author

augment review

@bagder

bagder commented Jan 25, 2026

Copy link
Copy Markdown
Member Author

Ref #1241

@augmentcode

augmentcode Bot commented Jan 25, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: Improve -J/--remote-header-name behavior across HTTP redirects by keeping a redirect-derived filename as a fallback when no Content-Disposition arrives.

Changes:

  • Extend the internal filename parsing helper to support different termination/stop rules.
  • Extract and store a candidate output filename from Location: headers (trim query/fragment) while following redirects.
  • Ensure a later Content-Disposition: filename= value overrides any previously captured redirect-derived filename.
  • Update documentation to describe the new fallback behavior (starting in 8.19.0).
  • Remove the corresponding item from docs/TODO.md now that it’s implemented.
  • Add new HTTP tests covering redirect + Content-Disposition and redirect-only (Location-derived) naming, including multiple redirects.

Technical Notes: The redirect fallback uses the last Location: header seen and strips ?/# components before extracting the final path segment as a filename.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread src/tool_cb_hdr.c Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/tool_cb_hdr.c Outdated
Comment thread src/tool_cb_hdr.c Outdated
bagder added a commit that referenced this pull request Jan 26, 2026
The -J / --remote-header-name logic now records the file name part used
in the redirects so that it can use the last one as a name if no
Content-Disposition header arrives.

Add tests to verify:

1641: -J with a redirect and extract the CD contents in the second
response

1642: -J with a redirect but no Content-Disposition, use the name from
the Location: header

1643: -J with two redirects, using the last file name and also use
queries and fragments to verify them stripped off

Closes #20430
@bagder
bagder force-pushed the bagder/redirect-cd branch from f73bf77 to 58f2529 Compare January 26, 2026 06:59
@bagder

bagder commented Jan 26, 2026

Copy link
Copy Markdown
Member Author

augment review

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread src/tool_cb_hdr.c
Comment thread src/tool_cb_hdr.c

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/tool_cb_hdr.c Outdated
Comment thread src/tool_cb_hdr.c Outdated
Comment thread src/tool_cb_hdr.c Outdated
Comment thread tests/data/test1643
The -J / --remote-header-name logic now records the file name part used
in the redirects so that it can use the last one as a name if no
Content-Disposition header arrives.

Add tests to verify:

1641: -J with a redirect and extract the CD contents in the second
response

1642: -J with a redirect but no Content-Disposition, use the name from
the Location: header

1643: -J with two redirects, using the last file name and also use
queries and fragments to verify them stripped off

Closes #20430
@bagder
bagder force-pushed the bagder/redirect-cd branch from f526c8e to bb7ec56 Compare January 26, 2026 08:06
@testclutch

This comment was marked as resolved.

@bagder bagder closed this in fa6a464 Jan 26, 2026
@bagder
bagder deleted the bagder/redirect-cd branch January 26, 2026 11:53
@bagder

bagder commented Jan 28, 2026

Copy link
Copy Markdown
Member Author

@aisle-analyzer

@aisle-research-bot

aisle-research-bot Bot commented Jan 29, 2026

Copy link
Copy Markdown

🔒 Aisle Security Analysis

✅ We scanned this PR and did not find any security vulnerabilities.
Aisle supplements but does not replace security review.


Analyzed PR: #20430 at commit bb7ec56

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good

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

Development

Successfully merging this pull request may close these issues.

3 participants