require 'nitro/context' module Nitro module Request # Some useful mini methods for browser testing. # TODO: add testing for mac IE (an other platforms) # Different servers hold user agent in differnet # strings (unify this). def user_agent headers['HTTP_USER_AGENT'] || headers['USER-AGENT'] end def from_gecko? user_agent =~ /Gecko/ end alias_method :from_mozilla?, :from_gecko? def from_ie? user_agent =~ /MSIE/ end alias_method :from_msie?, :from_ie? def from_opera? user_agent =~ /Opera/ end def from_khtml? user_agent =~ /KTHML/ end alias_method :from_safari?, :from_khtml? def from_w3c? from_gecko? or from_khtml? or from_opera? end end end # * Chris Farmiloe