Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Curl#curl_headers: Work with 8 exit_status #17412

Merged
merged 2 commits into from
Jun 4, 2024

Conversation

samford
Copy link
Member

@samford samford commented Jun 3, 2024

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

I recently noticed that ~23 livecheck blocks using the HeaderMatch strategy were failing. Looking into it, these fail when using a HEAD request and retry with GET but the resulting response with the headers we want is simply discarded because the exit_status from curl is 8 ("weird server reply").

This resolves the issue by adding a special case for this exit status, so #curl_headers will return the headers in this scenario.

Library/Homebrew/utils/curl.rb Outdated Show resolved Hide resolved
@samford samford marked this pull request as draft June 3, 2024 11:29
@samford samford marked this pull request as draft June 3, 2024 11:29
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Looks good! Agreed on @Bo98's comment and good to merge after that.

Might be an idea to make the 8 and 22 here constants in this file so the code is a bit more self-documenting.

@samford samford force-pushed the curl-work-with-8-exit_status branch from 9774cec to f511ea6 Compare June 4, 2024 01:51
@samford samford marked this pull request as ready for review June 4, 2024 01:51
@samford
Copy link
Member Author

samford commented Jun 4, 2024

Updated to add constants for these curl exit status codes, using the names from libcurl documentation. Using constants (and explaining them where they're defined), I think we can rework the existing comment to simply explain why we special case them (though let me know if you disagree).

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Looking good @samford! Just some suggested style/name changes.

Library/Homebrew/utils/curl.rb Outdated Show resolved Hide resolved
Library/Homebrew/utils/curl.rb Outdated Show resolved Hide resolved
Library/Homebrew/utils/curl.rb Outdated Show resolved Hide resolved
Library/Homebrew/utils/curl.rb Outdated Show resolved Hide resolved
samford and others added 2 commits June 4, 2024 11:48
I recently noticed that ~23 `livecheck` blocks using the `HeaderMatch`
strategy were failing. Looking into it, these fail when using a `HEAD`
request and retry with `GET` but the resulting response with the
headers we want is simply discarded because the `exit_status` from
curl is 8 ("weird server reply").

This resolves the issue by adding a special case for this exit status,
so `#curl_headers` will return the headers in this scenario.
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
@samford samford force-pushed the curl-work-with-8-exit_status branch from f511ea6 to 8236a70 Compare June 4, 2024 15:59
@MikeMcQuaid MikeMcQuaid merged commit b5a8efc into Homebrew:master Jun 4, 2024
25 checks passed
@MikeMcQuaid
Copy link
Member

Thanks again @samford!

@samford samford deleted the curl-work-with-8-exit_status branch June 4, 2024 18:09
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.

None yet

4 participants