Strategy: Add --silent flag to DEFAULT_CURL_ARGS

Currently, only `Livecheck::Strategy::PAGE_HEADERS_CURL_ARGS` uses
the `--silent` option and `PAGE_CONTENT_CURL_ARGS` does not (though
there's no intention behind this omission). However, the
`#page_content` method should also use the `--silent` flag, to
prevent progress bar text (`#=#=#`, etc.) from appearing in output.

This is an issue because the regex that's used to identify `curl`
error messages in `stderr` (`^curl:.+$/`) will fail if leading
progress bar text is present. This leads to an ambiguous "cURL
failed without a detectable error" message instead of the actual
error message(s) from `curl`.

This commit addresses the issue by adding `--silent` to
`Livecheck::Strategy::DEFAULT_CURL_ARGS`, which both
`PAGE_HEADERS_CURL_ARGS` and `PAGE_CONTENT_CURL_ARGS` inherit.
This commit is contained in:
Sam Ford 2021-12-30 16:07:29 -05:00
parent 33d765150a
commit cb537eae52
No known key found for this signature in database
GPG Key ID: 95209E46C7FFDEFE

View File

@ -39,6 +39,9 @@ module Homebrew
DEFAULT_CURL_ARGS = [ DEFAULT_CURL_ARGS = [
# Follow redirections to handle mirrors, relocations, etc. # Follow redirections to handle mirrors, relocations, etc.
"--location", "--location",
# Avoid progress bar text, so we can reliably identify `curl` error
# messages in output
"--silent",
].freeze ].freeze
# `curl` arguments used in `Strategy#page_headers` method. # `curl` arguments used in `Strategy#page_headers` method.
@ -46,8 +49,7 @@ module Homebrew
# We only need the response head (not the body) # We only need the response head (not the body)
"--head", "--head",
# Some servers may not allow a HEAD request, so we use GET # Some servers may not allow a HEAD request, so we use GET
"--request", "GET", "--request", "GET"
"--silent"
] + DEFAULT_CURL_ARGS).freeze ] + DEFAULT_CURL_ARGS).freeze
# `curl` arguments used in `Strategy#page_content` method. # `curl` arguments used in `Strategy#page_content` method.