Merge branch 'default_http_user_agent'

This commit is contained in:
Akinori MUSHA 2014-08-18 16:26:51 +09:00
commit 1987805952
2 changed files with 7 additions and 2 deletions

View file

@ -58,7 +58,12 @@ module WebRequestConcern
end
def user_agent
interpolated['user_agent'].presence ||
interpolated['user_agent'].presence || self.class.default_user_agent
end
module ClassMethods
def default_user_agent
ENV.fetch('DEFAULT_HTTP_USER_AGENT', Faraday.new.headers[:user_agent])
end
end
end

View file

@ -50,7 +50,7 @@ module Agents
Set `force_encoding` to an encoding name if the website does not return a Content-Type header with a proper charset.
Set `user_agent` to a custom User-Agent name if the website does not like the default value ("Faraday v#{Faraday::VERSION}").
Set `user_agent` to a custom User-Agent name if the website does not like the default value (`#{default_user_agent}`).
The `headers` field is optional. When present, it should be a hash of headers to send with the request.