lib/u3d/utils.rb in u3d-1.3.2 vs lib/u3d/utils.rb in u3d-1.3.3
- old
+ new
@@ -32,10 +32,13 @@
# rubocop:disable Metrics/ModuleLength
module Utils
# Regex to capture each part of a version string (0.0.0x0)
CSIDL_LOCAL_APPDATA = 0x001c
UNITY_VERSION_REGEX = /(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:(\w)(?:(\d+))?)?/.freeze
+ MOZILLA_AGENT_HEADER = {
+ 'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:106.0) Gecko/20100101 Firefox/106.0'
+ }.freeze
class << self
def final_url(url, redirect_limit: 10)
follow_redirects(url, redirect_limit: redirect_limit, http_method: :head) do |request, _response|
request.uri.to_s
@@ -53,9 +56,12 @@
end
end
def follow_redirects(url, redirect_limit: 10, http_method: :get, request_headers: {}, &block)
raise 'Too many redirections' if redirect_limit.zero?
+
+ # Unity blocks the default Ruby agent, use another one
+ request_headers = MOZILLA_AGENT_HEADER.merge(request_headers)
response = nil
request = nil
uri = URI(url)
begin