Try getting page content with both headers
This commit is contained in:
parent
cc7b62c829
commit
e6a18803ea
@ -179,17 +179,14 @@ module Homebrew
|
|||||||
def self.page_content(url)
|
def self.page_content(url)
|
||||||
original_url = url
|
original_url = url
|
||||||
|
|
||||||
|
stderr = nil
|
||||||
|
[:default, :browser].each do |user_agent|
|
||||||
stdout, stderr, status = curl_with_workarounds(
|
stdout, stderr, status = curl_with_workarounds(
|
||||||
*PAGE_CONTENT_CURL_ARGS, url,
|
*PAGE_CONTENT_CURL_ARGS, url,
|
||||||
**DEFAULT_CURL_OPTIONS
|
**DEFAULT_CURL_OPTIONS,
|
||||||
|
user_agent: user_agent
|
||||||
)
|
)
|
||||||
|
next unless status.success?
|
||||||
unless status.success?
|
|
||||||
/^(?<error_msg>curl: \(\d+\) .+)/ =~ stderr
|
|
||||||
return {
|
|
||||||
messages: [error_msg.presence || "cURL failed without an error"],
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
# stdout contains the header information followed by the page content.
|
# stdout contains the header information followed by the page content.
|
||||||
# We use #scrub here to avoid "invalid byte sequence in UTF-8" errors.
|
# We use #scrub here to avoid "invalid byte sequence in UTF-8" errors.
|
||||||
@ -218,7 +215,13 @@ module Homebrew
|
|||||||
|
|
||||||
data = { content: output }
|
data = { content: output }
|
||||||
data[:final_url] = final_url if final_url.present? && final_url != original_url
|
data[:final_url] = final_url if final_url.present? && final_url != original_url
|
||||||
data
|
return data
|
||||||
|
end
|
||||||
|
|
||||||
|
/^(?<error_msg>curl: \(\d+\) .+)/ =~ stderr
|
||||||
|
{
|
||||||
|
messages: [error_msg.presence || "cURL failed without an error"],
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user