Class: Hawkins::Commands::LiveServe::SkipAnalyzer
- Inherits:
-
Object
- Object
- Hawkins::Commands::LiveServe::SkipAnalyzer
- Defined in:
- lib/hawkins/servlet.rb
Constant Summary collapse
- BAD_USER_AGENTS =
[%r{MSIE}].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #bad_browser? ⇒ Boolean
- #chunked? ⇒ Boolean
- #html? ⇒ Boolean
-
#initialize(req, res, options) ⇒ SkipAnalyzer
constructor
A new instance of SkipAnalyzer.
- #inline? ⇒ Boolean
- #skip_processing? ⇒ Boolean
Constructor Details
#initialize(req, res, options) ⇒ SkipAnalyzer
Returns a new instance of SkipAnalyzer.
14 15 16 17 18 |
# File 'lib/hawkins/servlet.rb', line 14 def initialize(req, res, ) @options = @req = req @res = res end |
Class Method Details
.skip_processing?(req, res, options) ⇒ Boolean
10 11 12 |
# File 'lib/hawkins/servlet.rb', line 10 def self.skip_processing?(req, res, ) new(req, res, ).skip_processing? end |
Instance Method Details
#bad_browser? ⇒ Boolean
32 33 34 |
# File 'lib/hawkins/servlet.rb', line 32 def bad_browser? BAD_USER_AGENTS.any? { |pattern| @req['User-Agent'] =~ pattern } end |
#chunked? ⇒ Boolean
24 25 26 |
# File 'lib/hawkins/servlet.rb', line 24 def chunked? @res['Transfer-Encoding'] == 'chunked' end |
#html? ⇒ Boolean
36 37 38 |
# File 'lib/hawkins/servlet.rb', line 36 def html? @res['Content-Type'] =~ %r{text/html} end |
#inline? ⇒ Boolean
28 29 30 |
# File 'lib/hawkins/servlet.rb', line 28 def inline? @res['Content-Disposition'] =~ %r{^inline} end |
#skip_processing? ⇒ Boolean
20 21 22 |
# File 'lib/hawkins/servlet.rb', line 20 def skip_processing? !html? || chunked? || inline? || bad_browser? end |