Erwin
2011-Jun-02 21:11 UTC
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
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Jason Fleetwood-Boldt
2011-Jun-02 21:19 UTC
Re: anyway to differentiate request from users via browsers and request from web API ?
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. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Erwin
2011-Jun-03 05:40 UTC
Re: anyway to differentiate request from users via browsers and request from web API ?
Thanks, so I''ll modify my code to filter only specific browser & versions and accept other User Agent erwin On Jun 2, 11:19 pm, Jason Fleetwood-Boldt <t...-eJ8lBn5LdNBhbmWW9KSYcQ@public.gmane.org> wrote:> 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.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.