diff options
Diffstat (limited to 'Library/Homebrew/cask/lib/hbc/url.rb')
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/url.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/url.rb b/Library/Homebrew/cask/lib/hbc/url.rb index 8c652657b..15da2ced2 100644 --- a/Library/Homebrew/cask/lib/hbc/url.rb +++ b/Library/Homebrew/cask/lib/hbc/url.rb @@ -1,6 +1,8 @@ module Hbc class URL - attr_reader :using, :revision, :trust_cert, :uri, :cookies, :referer, :data, :user_agent + FAKE_USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10) https://caskroom.github.io".freeze + + attr_reader :using, :revision, :trust_cert, :uri, :cookies, :referer, :data extend Forwardable def_delegators :uri, :path, :scheme, :to_s @@ -15,7 +17,7 @@ module Hbc def initialize(uri, options = {}) @uri = Hbc::UnderscoreSupportingURI.parse(uri) - @user_agent = options.fetch(:user_agent, :default) + @user_agent = options[:user_agent] @cookies = options[:cookies] @referer = options[:referer] @using = options[:using] @@ -23,5 +25,10 @@ module Hbc @trust_cert = options[:trust_cert] @data = options[:data] end + + def user_agent + return FAKE_USER_AGENT if @user_agent == :fake + @user_agent + end end end |
