HeaderMatch: pass all headers into strategy block#22124
Merged
MikeMcQuaid merged 2 commits intomainfrom May 3, 2026
Merged
Conversation
10 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the livecheck HeaderMatch strategy so strategy blocks can opt into receiving either a merged headers hash (headers) or the full array of per-response headers (all_headers), enabling version extraction from non-final redirect headers.
Changes:
- Change
HeaderMatch.versions_from_contentto accept an array of response header hashes and provide either merged headers or all headers to thestrategyblock based on the first block argument name. - Update
HeaderMatch.find_versionsto pass the full headers array through toversions_from_content. - Expand/update
HeaderMatchstrategy specs to cover the newall_headersbehavior and error handling.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| Library/Homebrew/livecheck/strategy/header_match.rb | Adjusts strategy logic to pass full headers array or merged hash into the strategy block and updates header parsing flow. |
| Library/Homebrew/test/livecheck/strategy/header_match_spec.rb | Updates tests for the new array-of-headers input and adds coverage for all_headers block behavior and signature validation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8cca5b9 to
fb8ecba
Compare
This modifies livecheck's `HeaderMatch` strategy to allow `strategy` blocks to use an `all_headers` argument to receive the original array of response headers rather than a merged hash that only includes the last instance of a given header. Over the years, we've encountered a few checks where a server makes multiple redirections (i.e., there are multiple responses with a `Location` header) but we need to target a `Location` header that isn't the last occurrence. This hasn't been possible due to the `merged_headers` setup, so we've simply worked around it. We recently ran into this shortcoming again in homebrew-cask but there isn't a way to work around it this time, so this is now strictly necessary. This implementation borrows from my prior art in the `Sparkle` strategy, where the name of the first argument to a `strategy` block is strictly enforced and the name dictates what value is provided. I've ensured that all `HeaderMatch` strategy blocks in core/cask use a `headers` argument, so they will continue working as expected.
This updates the `Sparkle` strategy's `strategy` block handling logic to incorporate improvements that were identified as part of working on `HeaderMatch` `strategy` block handling.
fb8ecba to
e26e98d
Compare
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.
brew lgtm(style, typechecking and tests) with your changes locally?This modifies livecheck's
HeaderMatchstrategy to allowstrategyblocks to use anall_headersargument to receive the original array of response headers rather than a merged hash that only includes the last instance of a given header. Over the years, we've encountered a few checks where a server makes multiple redirections (i.e., there are multiple responses with aLocationheader) but we need to target aLocationheader that isn't the last occurrence. This hasn't been possible due to themerged_headerssetup, so we've simply worked around it.We recently ran into this shortcoming again in homebrew-cask but there isn't a way to work around it this time, so this is now strictly necessary. This implementation borrows from my prior art in the
Sparklestrategy, where the name of the first argument to astrategyblock is strictly enforced and the name dictates what value is provided. I've ensured that allHeaderMatchstrategy blocks in core/cask use aheadersargument, so they will continue working as expected.