I am filtering requests to determine the browsers used by visitors and
eventually give him back a warning about supported browsers …
In the application_controller.rb I have a filter
before_filter :ensure_browser_supported
and a method to test the user_agent ( iE, Firefox, Safari, Chrome
and their versions…)
def ensure_browser_supported
if html? && cookies[:browser_unsupported] != ‘false’ &&
user_agent.unsupported? && session[:browser_unsupported].blank?
session[:return_to] = request.fullpath
render :template => “/layouts/unsupported_browser”, :layout =>
false
end
end
Doing some testing on external API request I’ll have to answer, I sent
a curl request and discover that it obviously failed passing the test
as the user agent is
“HTTP_USER_AGENT”=>"curl/7.19.7 (universal-apple-darwin10.0)
but I guess that a request from a remote server will have another
user_agent … am I right ?
I can add this user agent in the list , but is there any way to
differentiate request from browsers and from remote servers before
filtering the browsers… what could I check in the request ?
thanks for your feedback