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 56 exit_status #18279

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Library/Homebrew/utils/curl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ module Curl
# code that is >= 400.
CURL_HTTP_RETURNED_ERROR_EXIT_CODE = 22

# Error returned when curl gets an error from the lowest networking layers
# that the receiving of data failed.
CURL_RECV_ERROR_EXIT_CODE = 56

# This regex is used to extract the part of an ETag within quotation marks,
# ignoring any leading weak validator indicator (`W/`). This simplifies
# ETag comparison in `#curl_check_http_content`.
Expand All @@ -38,6 +42,7 @@ module Curl

private_constant :CURL_WEIRD_SERVER_REPLY_EXIT_CODE,
:CURL_HTTP_RETURNED_ERROR_EXIT_CODE,
:CURL_RECV_ERROR_EXIT_CODE,
:ETAG_VALUE_REGEX, :HTTP_RESPONSE_BODY_SEPARATOR,
:HTTP_STATUS_LINE_REGEX

Expand Down Expand Up @@ -237,8 +242,11 @@ def curl_headers(*args, wanted_headers: [], **options)

# We still receive usable headers with certain non-successful exit
# statuses, so we special case them below.
if result.success? ||
[CURL_WEIRD_SERVER_REPLY_EXIT_CODE, CURL_HTTP_RETURNED_ERROR_EXIT_CODE].include?(result.exit_status)
if result.success? || [
CURL_WEIRD_SERVER_REPLY_EXIT_CODE,
CURL_HTTP_RETURNED_ERROR_EXIT_CODE,
CURL_RECV_ERROR_EXIT_CODE,
].include?(result.exit_status)
parsed_output = parse_curl_output(result.stdout)

if request_args.empty?
Expand Down