Skip to content

Commit 8e89fa0

Browse files
author
Paul Niezborala
committed
[Fix] U3d::Utils: replace Ruby agent with another one to bypass 403 from Unity
1 parent 63b721b commit 8e89fa0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/u3d/utils.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ module Utils
3434
# Regex to capture each part of a version string (0.0.0x0)
3535
CSIDL_LOCAL_APPDATA = 0x001c
3636
UNITY_VERSION_REGEX = /(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:(\w)(?:(\d+))?)?/.freeze
37+
MOZILLA_AGENT_HEADER = {
38+
'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:106.0) Gecko/20100101 Firefox/106.0'
39+
}.freeze
3740

3841
class << self
3942
def final_url(url, redirect_limit: 10)
@@ -56,6 +59,9 @@ def page_content(url, redirect_limit: 10, request_headers: {})
5659
def follow_redirects(url, redirect_limit: 10, http_method: :get, request_headers: {}, &block)
5760
raise 'Too many redirections' if redirect_limit.zero?
5861

62+
# Unity blocks the default Ruby agent, use another one
63+
request_headers = MOZILLA_AGENT_HEADER.merge(request_headers)
64+
5965
response = nil
6066
request = nil
6167
uri = URI(url)

0 commit comments

Comments
 (0)