Anyway to differentiate request from users via browsers and request from web API?

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

On Jun 2, 2011, at 5:11 PM, Erwin wrote:

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…

I could be wrong, but I don’t think there is, that’s what the User Agent
is for.

Thanks, so I’ll modify my code to filter only specific browser &
versions and accept other User Agent

erwin

On Jun 2, 11:19pm, Jason Fleetwood-Boldt [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs