Skip to content

curl_download_strategy: fix caching edgecase - #23917

Merged
MikeMcQuaid merged 1 commit into
mainfrom
cache_invalidation_ideas
Sep 10, 2026
Merged

curl_download_strategy: fix caching edgecase#23917
MikeMcQuaid merged 1 commit into
mainfrom
cache_invalidation_ideas

Conversation

@bevanjkay

Copy link
Copy Markdown
Member
  • a redirect's text/html prevented the last-modified and content-length checks when the final response had no content-type

Resolves https://github.com/orgs/Homebrew/discussions/7045


  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include brew benchmark results.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

Claude with Opus 5 at High effort, with local review and testing.

Copilot AI balanced review requested due to automatic review settings September 10, 2026 01:01
@bevanjkay bevanjkay changed the title Read content type from the final response only curl_download_strategy: fix caching edgecase Sep 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

馃煛 Changes recommended

Cache validation can mix the final content type with size or timestamp metadata from an earlier redirect.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Fixes cache validation when an HTML redirect precedes a final response without a content type.

Changes:

  • Uses the final response鈥檚 content type for cache validation.
  • Adds a redirect regression test.
File summaries
File Description
Library/Homebrew/download_strategy/curl_download_strategy.rb Selects content type from the final response.
Library/Homebrew/test/download_strategies/curl_spec.rb Tests cache invalidation after an HTML redirect.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

馃挕 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread Library/Homebrew/download_strategy/curl_download_strategy.rb Outdated
- a redirect's `text/html` prevented the `last-modified` and
  `content-length` checks when the final response had no `content-type`
- casks with `sha256 :no_check` then reinstalled a stale download
  indefinitely, e.g. `bookends`
- a redirect's own `content-length` could likewise reject a valid
  cached download when the final response was chunked

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

馃煝 Approval recommended

The focused implementation correctly addresses redirect-header contamination and includes appropriate regression coverage.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Sep 10, 2026
Merged via the queue into main with commit 8b82f04 Sep 10, 2026
78 of 83 checks passed
@MikeMcQuaid
MikeMcQuaid deleted the cache_invalidation_ideas branch September 10, 2026 07:38
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.

4 participants