From 70822d2bdb7ac47b5ecc57abe087b0aa8cd54092 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 26 Sep 2019 04:58:18 +0200 Subject: [PATCH] Add workaround for `curl: (56) Unexpected EOF`. --- Library/Homebrew/utils/curl.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Library/Homebrew/utils/curl.rb b/Library/Homebrew/utils/curl.rb index e3b4cc24db..21cd492dbc 100644 --- a/Library/Homebrew/utils/curl.rb +++ b/Library/Homebrew/utils/curl.rb @@ -76,6 +76,23 @@ def curl_download(*args, to: nil, **options) end curl("--location", "--remote-time", "--continue-at", continue_at.to_s, "--output", destination, *args, **options) +rescue ErrorDuringExecution => e + # This is a workaround for https://github.com/curl/curl/issues/1618. + raise unless e.status.exitstatus == 56 # Unexpected EOF + + raise if args.include?("--http1.1") + + out = curl_output("-V").stdout + + # If `curl` doesn't support HTTP2, the exception is unrelated to this bug. + raise unless out.include?("HTTP2") + + # The bug is fixed in `curl` >= 7.60.0. + curl_version = out[/curl (\d+(\.\d+)+)/, 1] + raise if Gem::Version.new(curl_version) >= Gem::Version.new("7.60.0") + + args << "--http1.1" + retry end def curl_output(*args, secrets: [], **options)