Skip to content

Commit

Permalink
Curl#curl_headers: Work with 8 exit_status
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
samford committed Jun 3, 2024
1 parent e130e47 commit 9774cec
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Library/Homebrew/utils/curl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def curl_headers(*args, wanted_headers: [], **options)
)

# 22 means a non-successful HTTP status code, not a `curl` error, so we still got some headers.
if result.success? || result.exit_status == 22
if result.success? || result.exit_status == 8 || result.exit_status == 22
parsed_output = parse_curl_output(result.stdout)

if request_args.empty?
Expand All @@ -235,7 +235,7 @@ def curl_headers(*args, wanted_headers: [], **options)
next if (400..499).cover?(parsed_output.fetch(:responses).last&.fetch(:status_code).to_i)
end

return parsed_output if result.success?
return parsed_output if result.success? || result.exit_status == 8
end

result.assert_success!
Expand Down

0 comments on commit 9774cec

Please sign in to comment.