utils/curl: refactor curl_with_workarounds
This commit is contained in:
		
							parent
							
								
									c538d4d84e
								
							
						
					
					
						commit
						16f8638236
					
				@ -72,24 +72,23 @@ module Utils
 | 
				
			|||||||
                              env:  { "SSL_CERT_FILE" => nil }.merge(env),
 | 
					                              env:  { "SSL_CERT_FILE" => nil }.merge(env),
 | 
				
			||||||
                              **command_options
 | 
					                              **command_options
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if !result.success? && args.exclude?("--http1.1")
 | 
					      return result if result.success? || !args.exclude?("--http1.1")
 | 
				
			||||||
        # This is a workaround for https://github.com/curl/curl/issues/1618.
 | 
					 | 
				
			||||||
        if result.status.exitstatus == 56 # Unexpected EOF
 | 
					 | 
				
			||||||
          out = curl_output("-V").stdout
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
          # If `curl` doesn't support HTTP2, the exception is unrelated to this bug.
 | 
					      # Error in the HTTP2 framing layer
 | 
				
			||||||
          return result unless out.include?("HTTP2")
 | 
					      return curl_with_workarounds(*args, "--http1.1", **command_options, **options) if result.status.exitstatus == 16
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          # The bug is fixed in `curl` >= 7.60.0.
 | 
					      # This is a workaround for https://github.com/curl/curl/issues/1618.
 | 
				
			||||||
          curl_version = out[/curl (\d+(\.\d+)+)/, 1]
 | 
					      if result.status.exitstatus == 56 # Unexpected EOF
 | 
				
			||||||
          return result if Gem::Version.new(curl_version) >= Gem::Version.new("7.60.0")
 | 
					        out = curl_output("-V").stdout
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          return curl_with_workarounds(*args, "--http1.1", **command_options, **options)
 | 
					        # If `curl` doesn't support HTTP2, the exception is unrelated to this bug.
 | 
				
			||||||
        end
 | 
					        return result unless out.include?("HTTP2")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if result.status.exitstatus == 16 # Error in the HTTP2 framing layer
 | 
					        # The bug is fixed in `curl` >= 7.60.0.
 | 
				
			||||||
          return curl_with_workarounds(*args, "--http1.1", **command_options, **options)
 | 
					        curl_version = out[/curl (\d+(\.\d+)+)/, 1]
 | 
				
			||||||
        end
 | 
					        return result if Gem::Version.new(curl_version) >= Gem::Version.new("7.60.0")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return curl_with_workarounds(*args, "--http1.1", **command_options, **options)
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      result
 | 
					      result
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user